Changes
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m20s Details

This commit is contained in:
Ravi Gulhane 2026-10-28 10:54:10 +05:30
parent cc0b8144d3
commit b6121f9980
3 changed files with 170 additions and 121 deletions

View File

@ -126,64 +126,28 @@ class AdherencePobDriveExport
'Days Daily Target Met',
'Target Status',
];
$summaryHelp = [
'No. of Total W',
'Count of Active TMs',
'No. of Total W x Count of Active TMs',
'Sum of count of all Days',
'Total TMs Qualified / Month Target (POBs)',
'No. of Unique Chemists with ≥₹15k POB Value',
'No. of Days on which Daily Target is achieved',
'If Month Target achieved = Achieved, If Month Target not achieved = In Progress',
];
$dayStart = count($identity) + 1;
$summaryStart = $dayStart + count($this->dayTemplate);
$lastCol = $summaryStart + count($summary) - 1;
$sheet->setCellValue('A1', 'Adherence Pack POB Drive – ABM – ' . $this->month);
$sheet->mergeCells('A1:' . $this->col($lastCol) . '1');
$sheet->setCellValue('A3', 'Legend: pink = vacant HQ; green day = working day; grey day = holiday.');
$sheet->mergeCells('A3:' . $this->col($lastCol) . '3');
$sheet->setCellValue('A5', 'Data of no. of chemists with Adherence Pack POB ≥ ₹15,000');
$sheet->setCellValue('J5', 'Day type (W / H) →');
$sheet->setCellValue('A1', 'Adherence Pack POB Drive – ABM');
$sheet->setCellValue('A3', 'Data of no. of chemists with Adherence Pack POB ≥ ₹15,000 will be added by Smartian App');
foreach ($this->dayTemplate as $index => $day) {
$sheet->setCellValue($this->col($dayStart + $index) . '5', $day['type'] === 'H' ? 'H' : 'W');
$sheet->setCellValue($this->col($dayStart + $index) . '4', $day['type'] === 'H' ? 'H' : 'W');
}
$help = [
'Zone',
'Region',
'Area',
'as it is',
'ABM Emp Name',
'ABM Emp Code',
'RBM Name',
'ABM Email ID',
'Count of Active TMs',
'Blank Remarks Column',
];
$this->writeValues($sheet, 6, $help);
if (count($this->dayTemplate) > 0) {
$sheet->setCellValue($this->col($dayStart) . '6', 'No. of TMs with at least 1 Chemist with ≥₹15k POB Value');
if (count($this->dayTemplate) > 1) {
$sheet->mergeCells($this->col($dayStart) . '6:' . $this->col($summaryStart - 1) . '6');
}
}
$this->writeValues($sheet, 6, $summaryHelp, $summaryStart);
$headers = $identity;
foreach ($this->dayTemplate as $day) {
$headers[] = $this->dayHeader($day['label']);
}
$headers = array_merge($headers, $summary);
$this->writeValues($sheet, 7, $headers);
$this->styleHeaderRow($sheet, 7, $lastCol, count($identity), $summaryStart);
$sheet->getStyle('A5')->getFont()->setName('Century Gothic')->setBold(true)->setSize(9)->getColor()->setARGB(self::BLUE);
$this->paintDayTypes($sheet, 5, $dayStart, false);
$this->paintDayHeaders($sheet, 7, $dayStart, false);
$this->writeValues($sheet, 5, $headers);
$this->styleHeaderRow($sheet, 5, $lastCol, count($identity), $summaryStart);
$sheet->getStyle('A3')->getFont()->setName('Century Gothic')->setBold(true)->setSize(9)->getColor()->setARGB(self::BLUE);
$this->paintDayTypes($sheet, 4, $dayStart, false);
$this->paintDayHeaders($sheet, 5, $dayStart, false);
$rowNumber = 8;
$rowNumber = 6;
foreach ($this->abmRows as $row) {
$values = [];
foreach ($identity as $key) {
@ -204,49 +168,31 @@ class AdherencePobDriveExport
$rowNumber++;
}
$this->finishSheet($sheet, 7, max(7, $rowNumber - 1), $lastCol, $dayStart, 14);
$sheet->freezePane('A8');
$this->finishSheet($sheet, 5, max(5, $rowNumber - 1), $lastCol, $dayStart, 14);
$sheet->getStyle('A3')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
$sheet->freezePane('A6');
}
private function writeRegionSheet($sheet): void
{
$columns = $this->regionColumns();
$lastCol = 3 + count($columns);
$sheet->setCellValue('A1', 'Region-wise Daily Winner – Highest no. of chemists with Adherence Pack POB ≥ ₹15,000 – ' . $this->month);
$sheet->mergeCells('A1:' . $this->col($lastCol) . '1');
$sheet->setCellValue('A1', 'Region-wise Daily Winner – Highest no. of chemists with Adherence Pack POB ≥ ₹15,000');
$typeRow = ['', '', ''];
$helpRow = ['', '', ''];
$headerRow = ['Region (RBM)', 'RBM Name', 'RBM Employee Code'];
$pairHelp = 0;
foreach ($columns as $column) {
if ($column['kind'] === 'total-tm' || $column['kind'] === 'total-chemist') {
$typeRow[] = 'Sum of count of all Days';
$helpRow[] = $column['kind'] === 'total-tm'
? 'No. of TMs with at least 1 Chemist with ≥₹15k POB Value'
: 'No. of Unique Chemists with ≥₹15k POB Value';
$typeRow[] = '';
$headerRow[] = $column['header'];
continue;
}
$typeRow[] = $column['type'] === 'H' ? 'H' : 'W';
if ($pairHelp === 0 && $column['kind'] === 'tm') {
$helpRow[] = 'No. of TMs with at least 1 Chemist with ≥₹15k POB Value';
$pairHelp = 1;
} elseif ($pairHelp === 1 && $column['kind'] === 'chemist') {
$helpRow[] = 'No. of Unique Chemists with ≥₹15k POB Value';
$pairHelp = 2;
} else {
$helpRow[] = '';
}
$headerRow[] = $column['header'];
}
$this->writeValues($sheet, 2, $typeRow);
$this->writeValues($sheet, 3, $helpRow);
$this->writeValues($sheet, 3, $typeRow);
$this->writeValues($sheet, 4, $headerRow);
if (count($columns) >= 2 && $columns[count($columns) - 1]['kind'] === 'total-chemist') {
$sheet->mergeCells($this->col($lastCol - 1) . '2:' . $this->col($lastCol) . '2');
}
$this->styleHeaderRow($sheet, 4, $lastCol, 3, $lastCol - 1);
$this->paintRegionDayMarks($sheet, $columns);
@ -288,30 +234,25 @@ class AdherencePobDriveExport
{
$dayStart = 4;
$totalCol = $dayStart + count($this->dayTemplate);
$sheet->setCellValue('A1', 'Territory-wise Daily Winner – Highest no. of chemists with Adherence Pack POB ≥ ₹15,000 – ' . $this->month);
$sheet->mergeCells('A1:' . $this->col($totalCol) . '1');
$sheet->setCellValue('A1', 'Territory-wise Daily Winner – Highest no. of chemists with Adherence Pack POB ≥ ₹15,000');
$typeRow = ['', '', ''];
foreach ($this->dayTemplate as $day) {
$typeRow[] = $day['type'] === 'H' ? 'H' : 'W';
}
$this->writeValues($sheet, 3, $typeRow);
if (count($this->dayTemplate) > 0) {
$sheet->setCellValue('D4', 'No. of Unique Chemists with ≥₹15k POB Value');
}
$sheet->setCellValue($this->col($totalCol) . '4', 'Sum of all Days of No. of Unique Chemists with ≥₹15k POB Value');
$headers = ['Territory', 'TM Name', 'TM Employee Code'];
foreach ($this->dayTemplate as $day) {
$headers[] = $this->dayHeader($day['label']);
}
$headers[] = 'Total Chemists Qualified (≥₹15k POB)';
$this->writeValues($sheet, 5, $headers);
$this->styleHeaderRow($sheet, 5, $totalCol, 3, $totalCol);
$this->writeValues($sheet, 4, $headers);
$this->styleHeaderRow($sheet, 4, $totalCol, 3, $totalCol);
$this->paintDayTypes($sheet, 3, $dayStart, true);
$this->paintDayHeaders($sheet, 5, $dayStart, true);
$this->paintDayHeaders($sheet, 4, $dayStart, true);
$rowNumber = 6;
$rowNumber = 5;
foreach ($this->tmRows as $row) {
$dayMap = $this->dayMap($this->field($row, 'days'));
$values = [
@ -331,8 +272,8 @@ class AdherencePobDriveExport
$rowNumber++;
}
$this->finishSheet($sheet, 5, max(5, $rowNumber - 1), $totalCol, $dayStart, 13);
$sheet->freezePane('A6');
$this->finishSheet($sheet, 4, max(4, $rowNumber - 1), $totalCol, $dayStart, 13);
$sheet->freezePane('A5');
}
/**
@ -713,7 +654,7 @@ class AdherencePobDriveExport
}
$cell = $this->col(4 + $index);
$color = $column['type'] === 'H' ? self::GREY : self::GREEN;
$this->paintCell($sheet, $cell . '2', $color);
$this->paintCell($sheet, $cell . '3', $color);
$this->paintCell($sheet, $cell . '4', $color);
$sheet->getStyle($cell . '4')->getFont()->setBold(true)->setSize(11)->getColor()->setARGB('000000');
}

View File

@ -901,6 +901,72 @@ class FormController extends Controller
]);
}
$whatsapp = preg_replace('/\D+/', '', (string) ($post['whatsapp_mobile_number'] ?? ''));
if (strlen($whatsapp) > 10) {
$whatsapp = substr($whatsapp, -10);
}
$post['whatsapp_mobile_number'] = $whatsapp;
if (!preg_match('/^[6-9]\d{9}$/', $whatsapp)) {
return response()->json([
'status' => 'error',
'message' => 'WhatsApp number is invalid.',
'description' => 'Please enter a valid 10-digit WhatsApp mobile number starting with 6, 7, 8, or 9.',
]);
}
$whatsappExists = false;
$phoneContacts = LambdaRequest::getrequest('contact', 'contact/get_all', [
'keyword' => $whatsapp,
'start' => 0,
'length' => 10000,
], $accessToken);
if (isset($phoneContacts->data->items) && is_array($phoneContacts->data->items)) {
foreach ($phoneContacts->data->items as $item) {
$itemPhone = isset($item->phone) ? preg_replace('/\D+/', '', (string) $item->phone) : '';
if (strlen($itemPhone) > 10) {
$itemPhone = substr($itemPhone, -10);
}
if ($itemPhone === '' || $itemPhone !== $whatsapp) {
continue;
}
$itemId = isset($item->id) ? (string) $item->id : '';
if ($currentSubmissionId !== '' && $linkedContactId !== '' && $itemId === $linkedContactId) {
continue;
}
$whatsappExists = true;
break;
}
}
if (!$whatsappExists && isset($previousEntries->data->submissions) && is_array($previousEntries->data->submissions)) {
foreach ($previousEntries->data->submissions as $submission) {
$submissionId = isset($submission->id) ? (string) $submission->id : '';
if ($currentSubmissionId !== '' && $submissionId === $currentSubmissionId) {
continue;
}
$entryPhone = isset($submission->formdata->whatsapp_mobile_number)
? preg_replace('/\D+/', '', (string) $submission->formdata->whatsapp_mobile_number)
: '';
if (strlen($entryPhone) > 10) {
$entryPhone = substr($entryPhone, -10);
}
if ($entryPhone !== '' && $entryPhone === $whatsapp) {
$whatsappExists = true;
break;
}
}
}
if ($whatsappExists) {
return response()->json([
'status' => 'error',
'message' => 'Doctor with this WhatsApp number already exists.',
'description' => 'Please check the enrolled doctor list or use a different WhatsApp number.',
]);
}
// Create contact only on new enrolments (not edits)
if ($currentSubmissionId === '') {
$doctorName = trim((string) ($post['contact_id'] ?? ($post['doctor_name'] ?? '')));
@ -1543,6 +1609,33 @@ class FormController extends Controller
]);
}
if ($formdata->form_id == '1741155802-25a7600f-1613-4a82-af1d-f460a8f79ffa') {
$contactIds = [];
foreach (['contact_id', 'contact_id_2'] as $contactKey) {
$contactId = trim((string) ($post[$contactKey] ?? ''));
if ($contactId !== '' && strcasecmp($contactId, 'others') !== 0) {
$contactIds[] = $contactId;
}
}
$contactIds = array_values(array_unique($contactIds));
if ($contactIds !== [] && !empty($formdata->partition)) {
list($application, $domain) = explode('-', $formdata->partition);
$token = DB::table('users')->select('access_token')->where('domain', $domain)->where('permissions', 'like', '%contact_create%')->orderBy('updated_at', 'desc')->skip(0)->take(1)->get();
$userId = trim((string) ($post['user_id'] ?? ($formdata->user_id ?? '')));
if ($token->isNotEmpty() && $userId !== '') {
foreach ($contactIds as $contactId) {
LambdaRequest::postrequest('contact', 'contact/update', [
'domain' => $domain,
'application' => $application,
'user_id' => $userId,
'id' => $contactId,
'ardc_camps_ardc_poster_execution_dr_tagging' => 'Yes',
], $token[0]->access_token);
}
}
}
}
if($formdata->form_id == '1757055046-ba0eff4e-0d4a-4e90-b190-c59f12ef6edd') {
// if(isset($post['cresar_bs_launched']) && $post['cresar_bs_launched'] == 'Yes' ) {
list($application, $domain) = explode("-", $formdata->partition);

View File

@ -425,30 +425,36 @@
$('#execution-form-wrapper').hide()
function copyTgicsLink(text) {
if (navigator.clipboard && window.isSecureContext) {
return navigator.clipboard.writeText(text);
function fallbackCopy() {
return new Promise(function(resolve, reject) {
var textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.left = '-9999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var ok = document.execCommand('copy');
document.body.removeChild(textArea);
ok ? resolve() : reject();
} catch (err) {
document.body.removeChild(textArea);
reject(err);
}
});
}
return new Promise(function(resolve, reject) {
var textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.left = '-9999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var ok = document.execCommand('copy');
document.body.removeChild(textArea);
ok ? resolve() : reject();
} catch (err) {
document.body.removeChild(textArea);
reject(err);
}
});
if (navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
return navigator.clipboard.writeText(text).catch(function() {
return fallbackCopy();
});
}
return fallbackCopy();
}
$(document).on('click', '.btn-copy-tgics-link', function() {
var link = $(this).data('link') || '';
var link = $(this).attr('data-link') || '';
var $btn = $(this);
if (!link) {
return;
@ -460,6 +466,11 @@
$btn.html(original);
}, 1500);
}).catch(function() {
var $input = $btn.closest('.input-group').find('.tgics-doctor-link');
if ($input.length) {
$input.trigger('focus');
$input[0].select();
}
Swal.fire({
icon: 'error',
title: 'Unable to copy',
@ -527,11 +538,7 @@
$('#execution-contact_id').val(docid) */
$('#execution-id').val(selected['id'])
toggleOtherQualification('execution');
})
$('#report-form').on('submit', function(event) {
@ -579,21 +586,29 @@
$('#field-other_qualification').prop({"required":false});
$('#field-other_qualification').parent().hide();
function toggleOtherQualification(prefix) {
var $qualification = $('#' + prefix + '-qualification');
var $other = $('#' + prefix + '-other_qualification');
if (!$qualification.length || !$other.length) {
return;
}
if ($qualification.val() === 'Others') {
$other.parent().show();
$other.prop('required', true);
} else {
$other.val('');
$other.prop('required', false);
$other.parent().hide();
}
}
$('#field-qualification').on('change',function(){
let dropDown=$('#field-qualification').val();
if(dropDown==='Others'){
$('#field-other_qualification').parent().show();
$('#field-other_qualification').prop({"required":true});
}
else{
$('#field-other_qualification').parent().hide();
$('#field-other_qualification').prop({"required":false});
}
})
toggleOtherQualification('field');
toggleOtherQualification('execution');
$('#field-qualification, #execution-qualification').on('change', function() {
var prefix = this.id.indexOf('execution-') === 0 ? 'execution' : 'field';
toggleOtherQualification(prefix);
});
$('#field-contact_id,#field-city_town,#field-state,#field-other_qualification').on('input', function () {