diff --git a/.env.dist b/.env.dist index 09f03372..0262d765 100644 --- a/.env.dist +++ b/.env.dist @@ -81,4 +81,5 @@ API_VERSION=insert_api_version_here #SSL_ENABLE for websockets SSL_ENABLE=set_to_true_or_false +# for hub filtering round robin HUB_JO_KEY=hub_jo_count diff --git a/config/acl.yaml b/config/acl.yaml index 0f858fa9..b9b42afb 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -502,3 +502,17 @@ access_keys: label: Update - id: customer_tag.delete label: Delete + + - id: dealer + label: Dealer Access + acls: + - id: dealer.menu + label: Menu + - id: dealer.list + label: List + - id: dealer.add + label: Add + - id: dealer.update + label: Update + - id: dealer.delete + label: Delete diff --git a/config/api_acl.yaml b/config/api_acl.yaml index ab15187a..2e5bbdd3 100644 --- a/config/api_acl.yaml +++ b/config/api_acl.yaml @@ -62,3 +62,8 @@ access_keys: acls: - id: municipality.list label: List + - id: dealer + label: Dealer + acls: + - id: dealer.list + label: List diff --git a/config/menu.yaml b/config/menu.yaml index 35709ee0..fc4751fb 100644 --- a/config/menu.yaml +++ b/config/menu.yaml @@ -110,6 +110,10 @@ main_menu: acl: hub.menu label: Hub parent: location + - id: dealer_list + acl: dealer.list + label: Dealer + parent: location - id: geofence_list acl: geofence.menu label: Geofence diff --git a/config/routes/capi.yaml b/config/routes/capi.yaml index 5db14285..40e7b975 100644 --- a/config/routes/capi.yaml +++ b/config/routes/capi.yaml @@ -172,3 +172,9 @@ capi_municipality_list: path: /capi/municipality controller: App\Controller\CAPI\MunicipalityController::getAll methods: [GET] + +# dealer +capi_dealer_list: + path: /capi/dealers + controller: App\Controller\CAPI\DealerController::getAll + methods: [GET] diff --git a/config/routes/dealer.yaml b/config/routes/dealer.yaml new file mode 100644 index 00000000..4c37e46e --- /dev/null +++ b/config/routes/dealer.yaml @@ -0,0 +1,33 @@ +dealer_list: + path: /dealers + controller: App\Controller\DealerController::index + +dealer_rows: + path: /dealers/rows + controller: App\Controller\DealerController::rows + methods: [POST] + +dealer_create: + path: /dealers/create + controller: App\Controller\DealerController::addForm + methods: [GET] + +dealer_create_submit: + path: /dealers/create + controller: App\Controller\DealerController::addSubmit + methods: [POST] + +dealer_update: + path: /dealers/{id} + controller: App\Controller\DealerController::updateForm + methods: [GET] + +dealer_update_submit: + path: /dealers/{id} + controller: App\Controller\DealerController::updateSubmit + methods: [POST] + +dealer_delete: + path: /dealers/{id} + controller: App\Controller\DealerController::destroy + methods: [DELETE] diff --git a/config/routes/report.yaml b/config/routes/report.yaml index f9d780ef..02f12f41 100644 --- a/config/routes/report.yaml +++ b/config/routes/report.yaml @@ -73,9 +73,9 @@ rep_warranty_details_form: controller: App\Controller\ReportController::warrantyDetailsForm methods: [GET] -rep_warranty_details_export_csv: +rep_warranty_details_submit: path: /report/warranty_details_report - controller: App\Controller\ReportController::warrantyDetailsExportCSV + controller: App\Controller\ReportController::warrantyDetailsSubmit methods: [POST] rep_jo_details_form: diff --git a/src/Command/CreateCustomerFromWarrantyCommand.php b/src/Command/CreateCustomerFromWarrantyCommand.php index 416ee514..5ffe3a46 100644 --- a/src/Command/CreateCustomerFromWarrantyCommand.php +++ b/src/Command/CreateCustomerFromWarrantyCommand.php @@ -216,7 +216,8 @@ class CreateCustomerFromWarrantyCommand extends Command $new_cust = new Customer(); $new_cust->setFirstName($w_first_name) ->setLastName($w_last_name) - ->setPhoneMobile($w_mobile_num); + ->setPhoneMobile($w_mobile_num) + ->setCreateSource('CMB_CreateCustomerFromWarranty'); $this->em->persist($new_cust); diff --git a/src/Command/GenerateWarrantyFromJobOrderCommand.php b/src/Command/GenerateWarrantyFromJobOrderCommand.php index 1e8e391a..381823d8 100644 --- a/src/Command/GenerateWarrantyFromJobOrderCommand.php +++ b/src/Command/GenerateWarrantyFromJobOrderCommand.php @@ -210,9 +210,10 @@ class GenerateWarrantyFromJobOrderCommand extends Command $values = '(' . $bty_model_id . ',' . $bty_size_id . ',NULL,\'' . $warranty_class . '\',\'' . $cleaned_plate_number . '\',\'' . WarrantyStatus::ACTIVE . '\',\'' . $date_create . '\',\'' . $date_purchase . '\',\'' . $date_expire . '\',NULL,' - . $sap_code . ',NULL,\'' . $first_name . '\',\'' . $last_name . '\',\'' . $mobile_number . '\',' . 0 . ',NULL' . ');'; + . $sap_code . ',NULL,\'' . $first_name . '\',\'' . $last_name . '\',\'' . $mobile_number . '\',' . 0 . ',NULL,\'' + . WarrantySource::COMMAND .'\');'; - $sql_statement = 'INSERT INTO `warranty` (bty_model_id,bty_size_id,serial,warranty_class,plate_number,status,date_create,date_purchase,date_expire,date_claim,sap_bty_id,claim_id,first_name,last_name,mobile_number,flag_activated,warranty_privacy_policy) VALUES ' . $values . "\n"; + $sql_statement = 'INSERT INTO `warranty` (bty_model_id,bty_size_id,serial,warranty_class,plate_number,status,date_create,date_purchase,date_expire,date_claim,sap_bty_id,claim_id,first_name,last_name,mobile_number,flag_activated,warranty_privacy_policy,create_source) VALUES ' . $values . "\n"; echo $sql_statement; diff --git a/src/Command/ImportCarClubCustomerDataCommand.php b/src/Command/ImportCarClubCustomerDataCommand.php index 49ef7679..5ae3b167 100644 --- a/src/Command/ImportCarClubCustomerDataCommand.php +++ b/src/Command/ImportCarClubCustomerDataCommand.php @@ -18,28 +18,11 @@ use App\Entity\CustomerTag; class ImportCarClubCustomerDataCommand extends Command { // field index in csv file - const F_TIMESTAMP = 0; - const F_DPA = 1; - const F_FIRST_NAME = 2; - const F_MIDDLE_NAME = 3; - const F_LAST_NAME = 4; - const F_BIRTHDATE = 5; - const F_ADDRESS = 6; - const F_CITY = 7; - const F_REGION = 8; - const F_CAR_CLUB = 9; - const F_POSITION = 10; - const F_MEMBER_NUM = 11; - const F_VEHICLE = 12; - const F_VEHICLE_EXCEL = 13; - const F_BATT_SIZE = 14; - const F_REPLACE_SKED = 15; - const F_DEALER_VISIT = 16; - const F_CONTACT_NUM = 17; - const F_BWI_LOCATION = 18; - const F_SAP_CODE = 19; - const F_SKU = 20; - const F_QTY = 21; + const F_DPA = 0; + const F_FIRST_NAME = 1; + const F_LAST_NAME = 2; + const F_CAR_CLUB = 3; + const F_CONTACT_NUM = 4; protected $em; protected $cust_tag_hash; @@ -145,54 +128,20 @@ class ImportCarClubCustomerDataCommand extends Command protected function setOutputInfo($fields, $status, $reason, $cust_id) { - $timestamp = trim($fields[self::F_TIMESTAMP]); - $mname = trim($fields[self::F_MIDDLE_NAME]); - $birthdate = trim($fields[self::F_BIRTHDATE]); - $address = trim($fields[self::F_ADDRESS]); - $city = trim($fields[self::F_CITY]); - $region = trim($fields[self::F_REGION]); $car_club = trim($fields[self::F_CAR_CLUB]); - $position = trim($fields[self::F_POSITION]); - $member_number = trim($fields[self::F_MEMBER_NUM]); - $vehicle = trim($fields[self::F_VEHICLE]); - $vehicle_excel = trim($fields[self::F_VEHICLE_EXCEL]); - $batt_size = trim($fields[self::F_BATT_SIZE]); - $replace_sked = trim($fields[self::F_REPLACE_SKED]); - $dealer_visit = trim($fields[self::F_DEALER_VISIT]); - $bwi_location = trim($fields[self::F_BWI_LOCATION]); - $sap_code = trim($fields[self::F_SAP_CODE]); - $sku = trim($fields[self::F_SKU]); - $qty = trim($fields[self::F_QTY]); $fname = trim($fields[self::F_FIRST_NAME]); $lname = trim($fields[self::F_LAST_NAME]); $dpa = trim($fields[self::F_DPA]); $contact_number = trim($fields[SELF::F_CONTACT_NUM]); return [ - $timestamp, $dpa, $fname, - $mname, $lname, - $birthdate, - $address, - $city, - $region, $car_club, - $position, - $member_number, - $vehicle, - $vehicle_excel, - $batt_size, - $replace_sked, - $dealer_visit, $contact_number, - $bwi_location, - $sap_code, - $sku, - $qty, - $status, - $reason, + $status, + $reason, $cust_id ]; } @@ -237,17 +186,6 @@ class ImportCarClubCustomerDataCommand extends Command // clean up contact number $valid_contact_numbers = $this->getValidContactNumbers($contact_number); - // NOTE: commenting this out because we want to add customers without mobile number - /* - // QUESTION: do we need this? - // QUESTION: why are we not adding those without contact numbers? Add customer, leave contact number blank was what was agreed, right? - if (count($valid_contact_numbers) <= 0) - { - // add info to output array - return $this->setOutputInfo($fields, 'NOT CREATED', 'Missing contact number', 0); - } - */ - // check customer tag $cust_tag = $this->findCustomerTag($car_club); $cust_id = ''; @@ -310,28 +248,11 @@ class ImportCarClubCustomerDataCommand extends Command // write the headers fputcsv($fh, [ - 'Timestamp', 'I have read and understood and agreed to the confidentiality of this form request', 'First Name', - 'Middle Name', 'Last Name', - 'Birth date', - 'Address', - 'City', - 'Region', 'Car Club/Organization', - 'Position in the organization', - 'Official Member Number (type NA if not applicable)', - 'Vehicles you own? Year - Make -Model - Plate/Conduction number (ex 2017 NISSAN NAVARA ABC 1234) you can indicate all your vehicles', - 'If your were given a chance to EXperience the New Motolite Excel, Choose 1 vehicle and it\'s plate/conduction number', - 'What is the Battery size of the vehicle you with to EXperience the New Motolite Excel', - 'Given a specific date, when can you schedule your replacement?', - 'Will you be able to visit our dealer that we will assign nearest to you?', 'Contact Number', - 'BWI LOCATION', - 'SAP CODE', - 'SKU', - 'QTY', 'Status', 'Reason', 'Customer ID', diff --git a/src/Command/ImportCustomerCommand.php b/src/Command/ImportCustomerCommand.php index e2c55832..562c2df3 100644 --- a/src/Command/ImportCustomerCommand.php +++ b/src/Command/ImportCustomerCommand.php @@ -418,7 +418,8 @@ class ImportCustomerCommand extends Command $fields[self::F_OFFICE_PHONE], $fields[self::F_FAX], $fields[self::F_EMAIL], - isset($fields[self::F_NOTES]) ? $fields[self::F_NOTES] : '' + isset($fields[self::F_NOTES]) ? $fields[self::F_NOTES] : '', + 'CMB_ImportCustomerCommand' ]; $cust_row = str_replace('\\', '\\\\', implode('|', $cust_fields)) . "\n"; fputs($cust_file, $cust_row); diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 4e636e14..f5b49f00 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -30,6 +30,7 @@ use App\Ramcar\AdvanceOrderSlot; use App\Ramcar\AutoAssignStatus; use App\Ramcar\WarrantySource; use App\Ramcar\HubCriteria; +use App\Ramcar\CustomerSource; use App\Service\InvoiceGeneratorInterface; use App\Service\RisingTideGateway; @@ -44,7 +45,7 @@ use App\Service\PromoLogger; use App\Service\HubSelector; use App\Service\HubDistributor; use App\Service\HubFilterLogger; - + use App\Entity\MobileSession; use App\Entity\Customer; use App\Entity\VehicleManufacturer; @@ -420,6 +421,9 @@ class APIController extends Controller implements LoggedController if ($cust == null) { $cust = new Customer(); + + // set customer source + $cust->setCreateSource(CustomerSource::MOBILE); $em->persist($cust); $this->session->setCustomer($cust); @@ -3197,6 +3201,9 @@ class APIController extends Controller implements LoggedController { $warr = new Warranty(); $sms_msg = $trans->trans('warranty_register_confirm'); + + // set warranty source + $warr->setCreateSource($source); } // get sap battery @@ -3228,6 +3235,16 @@ class APIController extends Controller implements LoggedController return $res; } + $customer = $this->session->getCustomer(); + if ($customer != null) + { + $warr->setCustomer($customer); + // get customer vehicles + + $vehicle = $this->findCustomerVehicle($em, $customer, $req->request->get('plate_number')); + if ($vehicle != null) + $warr->setVehicle($vehicle); + } // create or update warranty entry $warr->setSerial($serial) @@ -3302,6 +3319,23 @@ class APIController extends Controller implements LoggedController return $cust; } + protected function findCustomerVehicle($em, $customer, $plate_number) + { + $clean_plate = Warranty::cleanPlateNumber($plate_number); + if ($clean_plate) + { + // find the customer vehicle and get the vehicle + $cv = $em->getRepository(CustomerVehicle::class)->findOneBy(['plate_number' => $clean_plate, 'customer' => $customer]); + if ($cv != null) + { + $vehicle = $cv->getVehicle(); + return $vehicle; + } + } + + return null; + } + protected function findNearestHub($jo, EntityManagerInterface $em, MapTools $map_tools) { // get the nearest 10 hubs diff --git a/src/Controller/AnalyticsController.php b/src/Controller/AnalyticsController.php index d18b10bb..98ebd399 100644 --- a/src/Controller/AnalyticsController.php +++ b/src/Controller/AnalyticsController.php @@ -21,6 +21,7 @@ use DateInterval; use App\Entity\JobOrder; use App\Entity\Hub; +use App\Entity\Battery; use App\Ramcar\ShiftSchedule; @@ -125,7 +126,7 @@ class AnalyticsController extends Controller // TODO: populate the hour_shift array, depending on the shift selected $hour_shifts = $this->populateHourShift($shift); - error_log(print_r($hour_shifts, true)); + // error_log(print_r($hour_shifts, true)); // error_log(print_r($hub_list, true)); // $hub_list = [ 6, 4, 36, 7, 8, 126, 127, 18, 12, 9, 60, 10, 21, 135 ]; @@ -195,7 +196,7 @@ class AnalyticsController extends Controller // error_log(print_r($chart_all_weekdays, true)); - error_log(print_r($sched_res, true)); + // error_log(print_r($sched_res, true)); // agggregate weekday data $i = 0; @@ -367,6 +368,22 @@ class AnalyticsController extends Controller // get job order data (job orders within coverage area) $jos = $this->generateJobOrderData($conn, $hub, $distance_limit, $date_start, $date_end, $time_start, $time_end); + // get most bought battery from these JOs + $batt_id = $this->getHubBattery($conn, $jos); + $batt = $em->getRepository(Battery::class)->find($batt_id); + if ($batt == null) + $batt_data = [ + 'mfg' => 'None', + 'model' => 'None', + 'size' => 'None', + ]; + else + $batt_data = [ + 'mfg' => $batt->getManufacturer()->getName(), + 'model' => $batt->getModel()->getName(), + 'size' => $batt->getSize()->getName(), + ]; + // initialize counters $c_weekday = []; $c_day = []; @@ -433,12 +450,63 @@ class AnalyticsController extends Controller 'data_year' => $chart_year, // 'data_weekday' => $chart_weekday, 'c_weekday' => $c_weekday, // sending raw weekday data because we need to process overlaps + 'battery' => $batt_data, // TODO: refactor this pls ]; return $params; } + protected function getHubBattery($conn, $jos) + { + // collect ids + $ids = []; + foreach ($jos as $jo) + { + $ids[] = $jo['id']; + } + + // no jos, so no battery + if (count($ids) <= 0) + { + return 0; + } + + // ideally we encode the ids, but right now we're assuming they'll be int + $in_text = implode(',', $ids); + + // get all the batteries ordered in these JOs + $sql = 'select battery_id, count(*) as total from invoice i,invoice_item item where i.id = item.invoice_id and i.job_order_id in (' . $in_text . ') group by battery_id'; + + $stmt = $conn->prepare($sql); + + $stmt->execute(); + $batteries = $stmt->fetchAll(); + + // error_log(print_r($batteries, true)); + + + // get the most ordered, skipping the null battery + $best_batt_id = 0; + $best_batt_count = 0; + foreach ($batteries as $batt) + { + if ($batt['battery_id'] == null) + continue; + + // if current battery is better than our best + if ($best_batt_count < $batt['total']) + { + $best_batt_id = $batt['battery_id']; + $best_batt_count = $batt['total']; + } + } + + error_log('BEST - ' . $best_batt_id . ' - ' . $best_batt_count); + + return $best_batt_id; + } + protected function generateJobOrderData($conn, $hub, $distance_limit, DateTime $date_start, DateTime $date_end, $time_start, $time_end) { $hub_coord = $hub->getCoordinates(); @@ -471,7 +539,10 @@ class AnalyticsController extends Controller $stmt->execute(); $jos = $stmt->fetchAll(); + /* error_log(count($jos)); + error_log(print_r($jos, true)); + */ return $jos; } diff --git a/src/Controller/CAPI/CustomerController.php b/src/Controller/CAPI/CustomerController.php index 55aae2bd..9148321e 100644 --- a/src/Controller/CAPI/CustomerController.php +++ b/src/Controller/CAPI/CustomerController.php @@ -154,10 +154,17 @@ class CustomerController extends APIController else { // customer not found + // get the api_user that made the call so that it gets added to the source + // source becomes CAPI_USER_ + $user_id = $_SERVER['HTTP_X_CATA_API_KEY']; + $username = $this->getUser()->getName(); + $source = 'CAPI_USER_' . $username; + $new_cust = new Customer(); $new_cust->setFirstName($first_name) ->setLastName($last_name) - ->setPhoneMobile($mobile_number); + ->setPhoneMobile($mobile_number) + ->setCreateSource($source); $em->persist($new_cust); diff --git a/src/Controller/CAPI/CustomerWarrantyController.php b/src/Controller/CAPI/CustomerWarrantyController.php index e0c74f22..0c1c869e 100644 --- a/src/Controller/CAPI/CustomerWarrantyController.php +++ b/src/Controller/CAPI/CustomerWarrantyController.php @@ -106,6 +106,7 @@ class CustomerWarrantyController extends APIController 'serial' => $serial, ]; $action = 'check'; + // TODO: we need to modify this later. $source = WarrantySource::CAPI; // check required parameters @@ -315,7 +316,11 @@ class CustomerWarrantyController extends APIController 'invoice' => $req->request->get('invoice'), ]; $action = 'create/update'; - $source = WarrantySource::CAPI; + + // get the api_user that made the call so that it gets added to the source + // source becomes CAPI_USER_ + $username = $this->getUser()->getName(); + $source = 'CAPI_USER_' . $username; error_log('SOURCE: ' . $source); @@ -425,6 +430,9 @@ class CustomerWarrantyController extends APIController { $warr = new Warranty(); $sms_message = $trans->trans('warranty_register_confirm'); + + // set warranty's create source + $warr->setCreateSource($source); } error_log('sap battery check'); @@ -484,7 +492,8 @@ class CustomerWarrantyController extends APIController ->setEmail($req->request->get('email')) ->setCreateSource('web_warranty') ->setPrivacyPromo($priv_promo) - ->setPhoneMobile($req->request->get('contact_num')); + ->setPhoneMobile($req->request->get('contact_num')) + ->setCreateSource($source); $em->persist($cust); } @@ -578,5 +587,4 @@ class CustomerWarrantyController extends APIController $rt->sendSMS($clean_num, 'MOTOLITE', $message); } - } diff --git a/src/Controller/CAPI/DealerController.php b/src/Controller/CAPI/DealerController.php new file mode 100644 index 00000000..c59e4a54 --- /dev/null +++ b/src/Controller/CAPI/DealerController.php @@ -0,0 +1,53 @@ +acl_gen = $acl_gen; + } + + public function getAll(EntityManagerInterface $em) + { + // get all dealer data order by dealer name + $this->denyAccessUnlessGranted('dealer.list', null, 'No access.'); + + $results = $em->getRepository(Dealer::class)->findBy([], ['name' => 'ASC']); + + $dealers = []; + foreach($results as $res) + { + $dealer_id = $res->getId(); + $dealer_name = $res->getName(); + $dealer_address = $res->getAddress(); + $dealer_branch_code = $res->getBranchCode(); + + $dealers[$dealer_id] = [ + 'id' => $dealer_id, + 'name' => $dealer_name, + 'address' => $dealer_address, + 'branch_code' => $dealer_branch_code, + ]; + } + + $data = [ + 'dealers' => $dealers, + ]; + return new APIResponse(true, 'Dealers loaded.', $data); + } +} diff --git a/src/Controller/CAPI/WarrantyController.php b/src/Controller/CAPI/WarrantyController.php index 72eb1785..4db8051c 100644 --- a/src/Controller/CAPI/WarrantyController.php +++ b/src/Controller/CAPI/WarrantyController.php @@ -191,7 +191,12 @@ class WarrantyController extends APIController 'mobile_number' => $mnum, ]; $action = 'create'; - $source = WarrantySource::CAPI; + + // get the api_user that made the call so that it gets added to the source + // source becomes CAPI_USER_ + $username = $this->getUser()->getName(); + + $source = 'CAPI_USER_' . $username; $msg = $this->checkRequiredParameters($req, $params); error_log('msg - ' . $msg); @@ -275,7 +280,8 @@ class WarrantyController extends APIController ->setSAPBattery($batt) ->setDatePurchase($date_pur) ->setDateClaim(null) - ->setDateExpire($date_expire); + ->setDateExpire($date_expire) + ->setCreateSource($source); try { @@ -321,7 +327,12 @@ class WarrantyController extends APIController 'id' => $id, ]; $action = 'claim'; - $source = WarrantySource::CAPI; + + // get the api_user that made the call so that it gets added to the source + // source becomes CAPI_USER_ + $username = $this->getAPIUsername($em, $user_id); + $source = 'CAPI_USER_' . $username; + $msg = $this->checkRequiredParameters($req, $params); if ($msg) @@ -370,7 +381,8 @@ class WarrantyController extends APIController ->setDatePurchase($warr->getDatePurchase()) ->setDateClaim(null) ->setDateExpire($warr->getDateExpire()) - ->setClaimedFrom($warr); + ->setClaimedFrom($warr) + ->setCreateSource($source); $em->persist($new_warr); @@ -716,10 +728,12 @@ class WarrantyController extends APIController $w_last_name = $warranty->getLastName(); $new_cust = new Customer(); - // TODO: add customer source + // add customer source + $cust_source = $warranty->getCreateSource(); $new_cust->setFirstName($w_first_name) ->setLastName($w_last_name) - ->setPhoneMobile($w_mobile_num); + ->setPhoneMobile($w_mobile_num) + ->setCreateSource($cust_source); $em->persist($new_cust); @@ -774,5 +788,4 @@ class WarrantyController extends APIController $customers = $em->getRepository(Customer::class)->findBy(['phone_mobile' => $number]); return $customers; } - } diff --git a/src/Controller/DealerController.php b/src/Controller/DealerController.php new file mode 100644 index 00000000..75c1e035 --- /dev/null +++ b/src/Controller/DealerController.php @@ -0,0 +1,271 @@ +denyAccessUnlessGranted('dealer.list', null, 'No access.'); + + return $this->render('dealer/list.html.twig'); + } + + public function rows(Request $req) + { + $this->denyAccessUnlessGranted('dealer.list', null, 'No access.'); + + // get query builder + $qb = $this->getDoctrine() + ->getRepository(Dealer::class) + ->createQueryBuilder('q'); + + // get datatable params + $datatable = $req->request->get('datatable'); + + // count total records + $tquery = $qb->select('COUNT(q)'); + $this->setQueryFilters($datatable, $tquery); + $total = $tquery->getQuery() + ->getSingleScalarResult(); + + // get current page number + $page = $datatable['pagination']['page'] ?? 1; + + $perpage = $datatable['pagination']['perpage']; + $offset = ($page - 1) * $perpage; + + // add metadata + $meta = [ + 'page' => $page, + 'perpage' => $perpage, + 'pages' => ceil($total / $perpage), + 'total' => $total, + 'sort' => 'asc', + 'field' => 'id' + ]; + + // build query + $query = $qb->select('q'); + $this->setQueryFilters($datatable, $query); + + // check if sorting is present, otherwise use default + if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) { + $order = $datatable['sort']['sort'] ?? 'asc'; + $query->orderBy('q.' . $datatable['sort']['field'], $order); + } else { + $query->orderBy('q.id', 'asc'); + } + + // get rows for this page + $obj_rows = $query->setFirstResult($offset) + ->setMaxResults($perpage) + ->getQuery() + ->getResult(); + + // process rows + $rows = []; + foreach ($obj_rows as $orow) { + // add row data + $row['id'] = $orow->getID(); + $row['name'] = $orow->getName(); + $row['address'] = $orow->getAddress(); + $row['branch_code'] = $orow->getBranchCode(); + + // add row metadata + $row['meta'] = [ + 'update_url' => '', + 'delete_url' => '' + ]; + + // add crud urls + if ($this->isGranted('dealer.update')) + $row['meta']['update_url'] = $this->generateUrl('dealer_update', ['id' => $row['id']]); + if ($this->isGranted('dealer.delete')) + $row['meta']['delete_url'] = $this->generateUrl('dealer_delete', ['id' => $row['id']]); + + $rows[] = $row; + } + + // response + return $this->json([ + 'meta' => $meta, + 'data' => $rows + ]); + + } + + /** + * @Menu(selected="dealer_list") + */ + public function addForm() + { + $this->denyAccessUnlessGranted('dealer.add', null, 'No access.'); + + $params = []; + $params['obj'] = new Dealer(); + $params['mode'] = 'create'; + + // response + return $this->render('dealer/form.html.twig', $params); + } + + public function addSubmit(Request $req, EncoderFactoryInterface $ef, ValidatorInterface $validator) + { + $this->denyAccessUnlessGranted('dealer.add', null, 'No access.'); + + // create new object + $em = $this->getDoctrine()->getManager(); + $obj = new Dealer(); + + $this->setObject($obj, $req); + + // validate + $errors = $validator->validate($obj); + + // initialize error list + $error_array = []; + + // add errors to list + foreach ($errors as $error) { + $error_array[$error->getPropertyPath()] = $error->getMessage(); + } + + // check if any errors were found + if (!empty($error_array)) { + // return validation failure response + return $this->json([ + 'success' => false, + 'errors' => $error_array + ], 422); + } + + // validated! save the entity + $em->persist($obj); + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + + /** + * @Menu(selected="dealer_list") + */ + public function updateForm($id) + { + $this->denyAccessUnlessGranted('dealer.update', null, 'No access.'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $obj = $em->getRepository(Dealer::class)->find($id); + + // make sure this row exists + if (empty($obj)) + throw $this->createNotFoundException('The item does not exist'); + + $params = []; + $params['obj'] = $obj; + $params['mode'] = 'update'; + + // response + return $this->render('dealer/form.html.twig', $params); + } + + public function updateSubmit(Request $req, EncoderFactoryInterface $ef, ValidatorInterface $validator, $id) + { + $this->denyAccessUnlessGranted('dealer.update', null, 'No access.'); + + // get object data + $em = $this->getDoctrine()->getManager(); + $obj = $em->getRepository(Dealer::class)->find($id); + + // make sure this object exists + if (empty($obj)) + throw $this->createNotFoundException('The item does not exist'); + + $this->setObject($obj, $req); + + // validate + $errors = $validator->validate($obj); + + // initialize error list + $error_array = []; + + // add errors to list + foreach ($errors as $error) { + $error_array[$error->getPropertyPath()] = $error->getMessage(); + } + + // check if any errors were found + if (!empty($error_array)) { + // return validation failure response + return $this->json([ + 'success' => false, + 'errors' => $error_array + ], 422); + } + + // validated! save the entity + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + + public function destroy($id) + { + $this->denyAccessUnlessGranted('dealer.delete', null, 'No access.'); + + // get object data + $em = $this->getDoctrine()->getManager(); + $obj = $em->getRepository(Dealer::class)->find($id); + + if (empty($obj)) + throw $this->createNotFoundException('The item does not exist'); + + // delete this object + $em->remove($obj); + $em->flush(); + + // response + $response = new Response(); + $response->setStatusCode(Response::HTTP_OK); + $response->send(); + } + + protected function setObject(Dealer $obj, Request $req) + { + // set and save values + $obj->setName($req->request->get('name')) + ->setAddress($req->request->get('address', '')) + ->setBranchCode($req->request->get('branch_code', '')); + } + + protected function setQueryFilters($datatable, QueryBuilder $query) + { + if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) { + $query->where('q.name LIKE :filter') + ->orWhere('q.address LIKE :filter') + ->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%'); + } + } +} diff --git a/src/Controller/ReportController.php b/src/Controller/ReportController.php index 86247929..f259619a 100644 --- a/src/Controller/ReportController.php +++ b/src/Controller/ReportController.php @@ -683,33 +683,80 @@ class ReportController extends Controller /** * @Menu(selected="outlet_list") */ - public function warrantyDetailsExportCSV(Request $resq, EntityManagerInterface $em) + public function warrantyDetailsSubmit(Request $req, EntityManagerInterface $em) { - $data = $this->getWarrantyDetailsData($em); + $data = $this->getWarrantyDetailsData($req, $em); $resp = new StreamedResponse(); $resp->setCallback(function() use ($data) { // csv output $csv_handle = fopen('php://output', 'w+'); fputcsv($csv_handle, [ + 'Customer ID', + 'Customer First Name', + 'Customer Last Name', + 'Customer Is Confirmed?', + 'Customer Classification', + 'Customer Has Mobile App?', + 'Customer Title', + 'Customer Is Active?', + 'Customer Mobile Phone', + 'Customer Landline Phone', + 'Customer Office Phone', + 'Customer Fax Phone', + 'Customer Email Address', + 'Customer Notes', + 'Customer Has Third Party Privacy Policy?', + 'Customer Has Promo Privacy Policy?', + 'Customer Is CSAT', + 'Customer Mobile App Privacy Policy ID', + 'Customer Third Party Policy ID', + 'Customer Promo Privacy ID', + 'Customer DPA Consent', + 'Customer Date Created', + 'Customer SMS Research Flag', + 'Customer Email Research Flag', + 'Customer Create Source', + 'Vehicle ID', + 'Vehicle Manufacturer ID', + 'Vehicle Make', + 'Vehicle Model Year From', + 'Vehicle Model Year To', + 'Vehicle Mobile App Flag', 'Warranty ID', - 'Serial', - 'Battery Model', - 'Battery Size', + 'Warranty Battery Model ID', + 'Warranty Battery Size ID', + 'Warranty Serial', 'Warranty Class', - 'Plate Number', - 'Status', - 'Date Created', - 'Date Purchased', - 'Expiry Date', - 'Date Claimed', - 'SAP Battery ID', - 'Claim ID', - 'Last Name', - 'First Name', - 'Mobile Number', - 'Privacy Policy Number', - 'Activated?', + 'Warranty Plate Number', + 'Warranty Status', + 'Warranty Date Created', + 'Warranty Date Purchased', + 'Warranty Expiry Date', + 'Warranty Date Claimed', + 'Warranty SAP Battery ID', + 'Warranty Claim ID', + 'Warranty First Name', + 'Warranty Last Name', + 'Warranty Mobile Number', + 'Warranty Is Activated?', + 'Warranty Privacy Policy Number', + 'Warranty Email Address', + 'Warranty Vehicle ID', + 'Warranty Customer ID', + 'Warranty File Invoice', + 'Warranty File Card', + 'Warranty Vehicle Model Year', + 'Warranty Odometer', + 'Warranty Dealer Name', + 'Warranty Dealer Address', + 'Warranty Contact Number', + 'Warranty Customer Address', + 'Warranty Customer Date Purchase', + 'Warranty Is Validated?', + 'Warranty Province ID', + 'Warranty Municipality ID', + 'Warranty Create Source', ]); foreach ($data as $row) @@ -1421,23 +1468,53 @@ class ReportController extends Controller return $results; } - protected function getWarrantyDetailsData(EntityManagerInterface $em) + protected function getWarrantyDetailsData(Request $req, EntityManagerInterface $em) { $bm_hash = $this->loadBatteryModels($em); $bs_hash = $this->loadBatterySizes($em); + // get dates + $raw_date_start = $req->request->get('date_start'); + $raw_date_end = $req->request->get('date_end'); + + $date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start); + $date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end); + $date_start->setTime(0,0); + $date_end->setTime(23,59); + + // convert to string in the correct format so we can plug it in the query + $str_date_start = $date_start->format('Y-m-d H:i:s'); + $str_date_end = $date_end->format('Y-m-d H:i:s'); + $results = []; $conn = $em->getConnection(); - $sql = 'SELECT w.id, w.serial, w.warranty_class, w.plate_number, - w.status, w.date_create, w.date_purchase, w.date_expire, + $sql = 'SELECT w.id AS w_id, w.serial, w.warranty_class, w.plate_number, + w.status, w.date_create as w_date_create, w.date_purchase, w.date_expire, w.date_claim, w.sap_bty_id, w.claim_id, w.first_name, w.last_name, w.mobile_number, w.flag_activated, - w.warranty_privacy_policy, w.bty_model_id, w.bty_size_id - FROM warranty w'; + w.warranty_privacy_policy, w.bty_model_id, w.bty_size_id, + w.email as w_email, w.vehicle_id, w.customer_id, w.file_invoice, + w.file_warr_card, w.v_model_year, w.odometer, w.dealer_name, + w.dealer_address, w.contact_num, w.cust_address, + w.date_purchase_cust, w.flag_validated, w.province_id, + w.municipality_id, w.create_source AS w_create_source, c.id AS c_id, + c.first_name AS c_fname, c.last_name AS c_lname, c.flag_confirmed, + c.customer_classification, c.flag_mobile_app, c.title, c.flag_active, + c.phone_mobile, c.phone_landline, c.phone_office, c.phone_fax, + c.email AS c_email, c.customer_notes, c.priv_third_party, c.priv_promo, + c.flag_csat, c.policy_mobile_app_id, c.policy_third_party_id, + c.policy_promo_id, c.flag_dpa_consent, c.date_create AS c_date_create, + c.flag_research_sms, c.flag_research_email, c.create_source AS c_create_source, + v.id AS v_id, v.manufacturer_id, v.make, v.model_year_from, + v.model_year_to, v.flag_mobile + FROM warranty w LEFT JOIN customer c ON w.customer_id = c.id + LEFT JOIN vehicle v ON w.vehicle_id = v.id + WHERE w.date_create >= :start_date + AND w.date_create <= :end_date'; $stmt = $conn->prepare($sql); - $stmt->execute(); + $stmt->execute(['start_date' => $str_date_start, 'end_date' => $str_date_end]); $query_results = $stmt->fetchAll(); @@ -1461,24 +1538,71 @@ class ReportController extends Controller } $results[] = [ - 'id' => $row['id'], - 'serial' => $row['serial'], - 'battery_model' => $bmodel_name, - 'battery_size' => $bsize_name, - 'warranty_class' => $row['warranty_class'], - 'plate_number' => $row['plate_number'], - 'status' => $row['status'], - 'date_create' => $row['date_create'], - 'date_purchase' => $row['date_purchase'], - 'date_expire' => $row['date_expire'], - 'date_claim' => $row['date_claim'], - 'sap_bty_id' => $row['sap_bty_id'], - 'claim_id' => $row['claim_id'], - 'last_name' => $row['last_name'], - 'first_name' => $row['first_name'], - 'mobile_number' => $row['mobile_number'], - 'privacy_policy' => $row['warranty_privacy_policy'], - 'flag_activated' => (boolean) $row['flag_activated'], + 'cust_id' => $row['c_id'], + 'cust_first_name' => $row['c_fname'], + 'cust_last_name' => $row['c_lname'], + 'cust_flag_confirm' => $row['flag_confirmed'], + 'cust_classification' => $row['customer_classification'], + 'cust_flag_mobile_app' => $row['flag_mobile_app'], + 'cust_title' => $row['title'], + 'cust_flag_active' => $row['flag_active'], + 'cust_phone_mobile' => $row['phone_mobile'], + 'cust_phone_landline' => $row['phone_landline'], + 'cust_phone_office' => $row['phone_office'], + 'cust_phone_fax' => $row['phone_fax'], + 'cust_email' => $row['c_email'], + 'cust_notes' => $row['customer_notes'], + 'cust_priv_third_party' => $row['priv_third_party'], + 'cust_priv_promo' => $row['priv_promo'], + 'cust_flag_csat' => $row['flag_csat'], + 'cust_policy_mobile_app_id' => $row['policy_mobile_app_id'], + 'cust_policy_third_party_id' => $row['policy_third_party_id'], + 'cust_policy_promo_id' => $row['policy_promo_id'], + 'cust_flag_dpa_consent' => $row['flag_dpa_consent'], + 'cust_date_create' => $row['c_date_create'], + 'cust_flag_research_sms' => $row['flag_research_sms'], + 'cust_flag_research_email' => $row['flag_research_email'], + 'cust_create_source' => $row['c_create_source'], + 'v_id' => $row['v_id'], + 'v_manufacturer_id' => $row['manufacturer_id'], + 'v_make' => $row['make'], + 'v_model_year_from' => $row['model_year_from'], + 'v_model_year_to' => $row['model_year_to'], + 'v.flag_mobile' => $row['flag_mobile'], + 'warr_id' => $row['w_id'], + 'warr_battery_model' => $bmodel_name, + 'warr_battery_size' => $bsize_name, + 'warr_serial' => $row['serial'], + 'warr_class' => $row['warranty_class'], + 'warr_plate_number' => $row['plate_number'], + 'warr_status' => $row['status'], + 'warr_date_create' => $row['w_date_create'], + 'warr_date_purchase' => $row['date_purchase'], + 'warr_date_expire' => $row['date_expire'], + 'warr_date_claim' => $row['date_claim'], + 'warr_sap_bty_id' => $row['sap_bty_id'], + 'warr_claim_id' => $row['claim_id'], + 'warr_first_name' => $row['first_name'], + 'warr_last_name' => $row['last_name'], + 'warr_mobile_number' => $row['mobile_number'], + 'warr_flag_activated' => (boolean) $row['flag_activated'], + 'warr_privacy_policy' => $row['warranty_privacy_policy'], + 'warr_email' => $row['w_email'], + 'warr_vehicle_id' =>$row['vehicle_id'], + 'warr_customer_id' => $row['customer_id'], + 'warr_file_invoice' => $row['file_invoice'], + 'warr_file_warr_card' => $row['file_warr_card'], + 'warr_v_model_year' => $row['v_model_year'], + 'warr_odometer' => $row['odometer'], + 'warr_dealer_name' => $row['dealer_name'], + 'warr_dealer_address' => $row['dealer_address'], + 'warr_contact_number' => $row['contact_num'], + 'warr_customer_address' => $row['cust_address'], + 'warr_customer_date_purchase' => $row['date_purchase_cust'], + 'warr_flag_validated' => $row['flag_validated'], + 'warr_province_id' => $row['province_id'], + 'warr_municipality_id' => $row['municipality_id'], + 'warr_create_source' => $row['w_create_source'], ]; } diff --git a/src/Controller/TicketController.php b/src/Controller/TicketController.php index c79aedd2..303b34a6 100644 --- a/src/Controller/TicketController.php +++ b/src/Controller/TicketController.php @@ -314,7 +314,7 @@ class TicketController extends Controller if (empty($obj)) throw $this->createNotFoundException('The item does not exist'); - $em = $this->getDoctrine()->getManager(); + // $em = $this->getDoctrine()->getManager(); $customer = $obj->getCustomer(); $job_order = $obj->getJobOrder(); @@ -337,6 +337,28 @@ class TicketController extends Controller $params['redirect_url'] = $cust_update_url; } + // optimized get related tickets + $rel_tix = []; + // one query for each so we use indeces + if (!empty($obj->getFirstName()) && !empty($obj->getLastName())) + $rel_tix[] = $em->getRepository(Ticket::class)->findBy(['first_name' => $obj->getFirstName(), 'last_name' => $obj->getLastName()]); + if (!empty($obj->getContactNumber())) + $rel_tix[] = $em->getRepository(Ticket::class)->findBy(['contact_num' => $obj->getContactNumber()]); + if (!empty($obj->getPlateNumber())) + $rel_tix[] = $em->getRepository(Ticket::class)->findBy(['plate_number' => $obj->getPlateNumber()]); + + $consolidated_rel_tix = []; + foreach ($rel_tix as $rel_tickets) + { + foreach ($rel_tickets as $rticket) + { + $rtid = $rticket->getID(); + $consolidated_rel_tix[$rtid] = $rticket; + } + } + $params['related_tickets'] = $consolidated_rel_tix; + + /* // get related tickets $qb = $em->getRepository(Ticket::class) ->createQueryBuilder('q'); @@ -353,6 +375,8 @@ class TicketController extends Controller $params['related_tickets'] = $query->getQuery() ->getResult(); + */ + $params['obj'] = $obj; diff --git a/src/Controller/WarrantyController.php b/src/Controller/WarrantyController.php index d7ab6eb7..af75e3b2 100644 --- a/src/Controller/WarrantyController.php +++ b/src/Controller/WarrantyController.php @@ -176,7 +176,8 @@ class WarrantyController extends Controller ->setMobileNumber($req->request->get('mobile_number')) ->setDatePurchase($date_purchase) ->setClaimedFrom($req->request->get('claim_from')) - ->setStatus($req->request->get('status')); + ->setStatus($req->request->get('status')) + ->setCreateSource(WarrantySource::ADMIN_PANEL); if ($date_claim) { diff --git a/src/Entity/Dealer.php b/src/Entity/Dealer.php new file mode 100644 index 00000000..b60fe20c --- /dev/null +++ b/src/Entity/Dealer.php @@ -0,0 +1,81 @@ +id; + } + + public function setName($name) + { + $this->name = $name; + return $this; + } + + public function getName() + { + return $this->name; + } + + public function setAddress($address) + { + $this->address = $address; + return $this; + } + + public function getAddress() + { + return $this->address; + } + + public function setBranchCode($branch_code) + { + $this->branch_code = $branch_code; + return $this; + } + + public function getBranchCode() + { + return $this->branch_code; + } +} diff --git a/src/Entity/Ticket.php b/src/Entity/Ticket.php index cdf44ab1..35882075 100644 --- a/src/Entity/Ticket.php +++ b/src/Entity/Ticket.php @@ -12,7 +12,12 @@ use DateTime; /** * @ORM\Entity - * @ORM\Table(name="ticket") + * @ORM\Table(name="ticket", indexes={ + * @ORM\Index(columns={"contact_num"}), + * @ORM\Index(columns={"plate_number"}), + * @ORM\Index(columns={"first_name"}), + * @ORM\Index(columns={"last_name"}) + * }) */ class Ticket { diff --git a/src/Entity/Warranty.php b/src/Entity/Warranty.php index a814856b..5d45e806 100644 --- a/src/Entity/Warranty.php +++ b/src/Entity/Warranty.php @@ -232,6 +232,11 @@ class Warranty */ protected $municipality_id; + /** + * @ORM\Column(type="string", length=80, options={"default": "legacy"}) + */ + protected $create_source; + public function __construct() { $this->date_create = new DateTime(); @@ -242,6 +247,7 @@ class Warranty $this->email = ''; $this->odometer = 0; $this->flag_validated = false; + $this->create_source = 'unknown'; } public function getID() @@ -658,4 +664,16 @@ class Warranty { return $this->municipality_id; } + + public function setCreateSource($source) + { + $this->create_source = $source; + return $this; + } + + public function getCreateSource() + { + return $this->create_source; + } + } diff --git a/src/Ramcar/CustomerSource.php b/src/Ramcar/CustomerSource.php new file mode 100644 index 00000000..5acfa41d --- /dev/null +++ b/src/Ramcar/CustomerSource.php @@ -0,0 +1,16 @@ + 'Mobile API', + 'admin_panel' => 'Admin Panel', + 'legacy' => 'Legacy', + ]; +} diff --git a/src/Ramcar/WarrantySource.php b/src/Ramcar/WarrantySource.php index 3c16ee89..be9c47e1 100644 --- a/src/Ramcar/WarrantySource.php +++ b/src/Ramcar/WarrantySource.php @@ -10,6 +10,7 @@ class WarrantySource extends NameValue const BULK_UPLOAD = 'bulk_upload'; const MOBILE = 'mobile'; const COMMAND = 'command'; + const UNKNOWN = 'unknown'; const COLLECTION = [ 'capi' => 'Third Party API', @@ -18,6 +19,7 @@ class WarrantySource extends NameValue 'bulk_upload' => 'Bulk Upload', 'mobile' => 'Mobile API', 'command' => 'Command', + 'unknown' => 'Unknown', ]; } diff --git a/src/Service/CustomerHandler/ResqCustomerHandler.php b/src/Service/CustomerHandler/ResqCustomerHandler.php index 1554a288..f8685801 100644 --- a/src/Service/CustomerHandler/ResqCustomerHandler.php +++ b/src/Service/CustomerHandler/ResqCustomerHandler.php @@ -15,6 +15,7 @@ use App\Ramcar\CustomerClassification; use App\Ramcar\FuelType; use App\Ramcar\VehicleStatusCondition; use App\Ramcar\CrudException; +use App\Ramcar\CustomerSource; use App\Entity\Customer; use App\Entity\CustomerVehicle; @@ -189,6 +190,9 @@ class ResqCustomerHandler implements CustomerHandlerInterface $this->setObject($row, $req); + // set customer source only when new customer + $row->setCreateSource(CustomerSource::ADMIN_PANEL); + // custom validation for vehicles $vehicles = json_decode($req->request->get('vehicles')); diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 7807a6c8..ec1533e2 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -1070,7 +1070,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $user_id = $user->getUsername(); $source = WarrantySource::ADMIN_PANEL; - $this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class, $user_id, $source); + $this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class, $user_id, $source, $obj->getCustomer(), $obj->getCustomerVehicle()->getVehicle()); } else error_log('Invalid plate number for warranty. Plate number = ' . $obj->getCustomerVehicle()->getPlateNumber()); diff --git a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php index 6f1711c3..10678139 100644 --- a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php @@ -602,7 +602,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface // for riders, use rider session id $user_id = $this->session->getID(); $source = WarrantySource::RAPI; - $this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class, $user_id, $source); + $this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class, $user_id, $source, $jo->getCustomer(), $jo->getCustomerVehicle()->getVehicle()); } // send mqtt event (fulfilled) diff --git a/src/Service/WarrantyHandler.php b/src/Service/WarrantyHandler.php index aadb8eac..7ba9c6f8 100644 --- a/src/Service/WarrantyHandler.php +++ b/src/Service/WarrantyHandler.php @@ -30,7 +30,8 @@ class WarrantyHandler } public function createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, - $batt_list, DateTime $date_purchase, $warranty_class, $user_id, $source) + $batt_list, DateTime $date_purchase, $warranty_class, $user_id, + $source, $customer, $cust_vehicle) { // new warranty $warranty = new Warranty(); @@ -93,7 +94,10 @@ class WarrantyHandler ->setLastName($last_name) ->setMobileNumber($mobile_number) ->setDatePurchase($date_purchase) - ->setWarrantyClass($warranty_class); + ->setWarrantyClass($warranty_class) + ->setCreateSource($source) + ->setCustomer($customer) + ->setVehicle($cust_vehicle); $this->em->persist($warranty); $this->em->flush(); @@ -361,7 +365,8 @@ class WarrantyHandler public function cleanPlateNumber($plate) { - // remove spaces and make upper case + // TODO: make this more like Warranty's static cleanPlateNumber? + // remove spaces and make upper case return strtoupper(str_replace(' ', '', $plate)); } diff --git a/templates/analytics/forecast_submit.html.twig b/templates/analytics/forecast_submit.html.twig index e9370e76..14fb5197 100644 --- a/templates/analytics/forecast_submit.html.twig +++ b/templates/analytics/forecast_submit.html.twig @@ -98,6 +98,10 @@
+
+ Recommended Extra Battery Inventory - {{ hub.battery.mfg }} - {{ hub.battery.model }} - {{ hub.battery.size }} +
+ diff --git a/templates/dealer/form.html.twig b/templates/dealer/form.html.twig new file mode 100644 index 00000000..9bcf906d --- /dev/null +++ b/templates/dealer/form.html.twig @@ -0,0 +1,154 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

Dealers

+
+
+
+ +
+ +
+
+
+
+
+
+ + + +

+ {% if mode == 'update' %} + Edit Dealer + {{ obj.getName() }} + {% else %} + New Dealer + {% endif %} +

+
+
+
+
+
+
+
+
+
+ + + +
+
+ + + +
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+ + Back +
+
+
+
+ +
+
+
+
+{% endblock %} + + +{% block scripts %} + +{% endblock %} diff --git a/templates/dealer/list.html.twig b/templates/dealer/list.html.twig new file mode 100644 index 00000000..f6428c6b --- /dev/null +++ b/templates/dealer/list.html.twig @@ -0,0 +1,151 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Dealers +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/report/warranty-details/form.html.twig b/templates/report/warranty-details/form.html.twig index c329785a..03229bbb 100644 --- a/templates/report/warranty-details/form.html.twig +++ b/templates/report/warranty-details/form.html.twig @@ -21,30 +21,65 @@
- +

- Generate Warranty Details CSV File + Select a date range

- -
-
-
-
-
- -
+ +
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+
+
{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/utils/get_warranty_serial/get_serials.php b/utils/get_warranty_serial/get_serials.php index 237ce266..e9538e3f 100644 --- a/utils/get_warranty_serial/get_serials.php +++ b/utils/get_warranty_serial/get_serials.php @@ -20,14 +20,20 @@ $conn_string = "BlobEndpoint=$blob_url;\nSharedAccessSignature=$sas_token"; $blob_client = BlobRestProxy::createBlobService($conn_string); -$current_date = new DateTime(); -$current_date->modify("-1 day"); +// get date argument +$proc_date = $argv[1]; -$date = $current_date->format('m-d-y'); +error_log($proc_date); -$filename = 'warrantylogs' . $date . '.csv'; -//print_r($filename); +//$current_date = new DateTime(); +//$current_date->modify("-1 day"); +//$date = $current_date->format('m-d-Y'); + +$filename = 'warrantylogs' . $proc_date . '.csv'; +error_log($filename); + +/* try { // NOTE: via download blob $res = $blob_client->getBlob('warranty', $filename); @@ -36,8 +42,7 @@ try { file_put_contents("/tmp/warranty_download_serial.txt", $res->getContentStream()); } catch (Exception $e) { file_put_contents("/tmp/serial_download_error.txt", $filename . "\n" . $e->getMessage() . "\n" . "\n", FILE_APPEND); -} - +} */ /* // NOTE: getting via url diff --git a/utils/get_warranty_serial/new_get_serials.php b/utils/get_warranty_serial/new_get_serials.php new file mode 100644 index 00000000..45161f3a --- /dev/null +++ b/utils/get_warranty_serial/new_get_serials.php @@ -0,0 +1,49 @@ +getBlob('warranty', $filename); + // print_r($res); + + if ($flag_overwrite > 0) + { + file_put_contents($output_file, $res->getContentStream()); + } + else + { + file_put_contents($output_file, "\r\n", FILE_APPEND); + file_put_contents($output_file, $res->getContentStream(), FILE_APPEND); + } +} catch (Exception $e) { + file_put_contents("/tmp/serial_download_error.txt", $filename . "\n" . $e->getMessage() . "\n" . "\n", FILE_APPEND); +} + + + + + diff --git a/utils/load_dealers/load_dealers.php b/utils/load_dealers/load_dealers.php new file mode 100644 index 00000000..efcc2eb5 --- /dev/null +++ b/utils/load_dealers/load_dealers.php @@ -0,0 +1,106 @@ +loadEnv(__DIR__.'/../../.env'); + + $db_info = $_ENV['DATABASE_URL']; + + // sample format of db_info: mysql://db_user:db_password@127.0.0.1:3306/resq?charset=utf8 + // dsn for PDO needs to be: mysql:host=127.0.0.1:3306;dbname=resq;charset=UTF8 + + preg_match('/^mysql:\/\/(.*):(.*)@(.*):(.*)\/(.*)\?(.*)/', $db_info, $result); + + $db_type = 'mysql:host='; + $user = $result[1]; + $pass = $result[2]; + $ip_port = $result[3] . ':' . $result[4] . ';'; + $db_name = 'dbname=' . $result[5] . ';'; + $charset = $result[6]; + + $dsn = $db_type . $ip_port . $db_name . $charset; + + $db_data = array($dsn, $user, $pass); + + return $db_data; +} + +// load csv +$csv = fopen($argv[1], 'r'); +$output_file = $argv[2]; + +$output_fh = fopen($output_file, "w"); + +if (!file_exists($argv[1])) +{ + $err_message = "No csv input file found." . "\n"; + fwrite($output_fh, $err_message); + fclose($output_fh); + exit(); +} + +list($dsn, $user, $pass) = getDatabaseInfo(); + +// error_log($dsn); +// error_log($user); +// error_log($pass); + +// connect to db +$db = new PDO($dsn, $user, $pass); + +// prepared statement +$sth = $db->prepare('insert into dealer (name, address, branch_code) values (:name, :address, :branch_code)'); + +$rownum = 0; +while (($row = fgetcsv($csv)) !== false) +{ + // dealer csv file has a header + if ($rownum < 1) + { + // skip header + $rownum++; + continue; + } + + // sample of line in csv file + // columns are name, address, branch code + // BATPARTS Marcos Branch,"Km. 16 Marcos Hi-way corner Mahogany Street, Santolan, Pasig",ZN03576282 + $dealer_name = trim(strtoupper($row[0])); + $dealer_address = trim(strtoupper($row[1])); + $dealer_branch_code = trim(strtoupper($row[2])); + + // error_log('name ' . $dealer_name . ' address ' . $dealer_address . ' branch code ' . $dealer_branch_code); + error_log('Processing ' . $dealer_name); + + $res = $sth->execute([ + ':name' => $dealer_name, + ':address' => $dealer_address, + ':branch_code' => $dealer_branch_code, + ]); + + if (!$res) + { + // log error + $err = $sth->errorInfo(); + $log_message = "$dealer_name - ERROR - " . $err[2] . "\n"; + } + else + { + // log successful adding of dealer + $log_message = "$dealer_name - SUCCESS - " . "\n"; + } + fwrite($output_fh, $log_message); + + $rownum++; +} + +// close file +fclose($csv); +fclose($output_fh); +?> diff --git a/utils/load_warranty_serial/load_serials.php b/utils/load_warranty_serial/load_serials.php index cd1cce90..c2bb5671 100644 --- a/utils/load_warranty_serial/load_serials.php +++ b/utils/load_warranty_serial/load_serials.php @@ -1,10 +1,48 @@ loadEnv(__DIR__.'/../../.env'); + +$db_info = $_ENV['DATABASE_URL']; + +// sample format of db_info: mysql://db_user:db_password@127.0.0.1:3306/resq?charset=utf8 +// dsn for PDO needs to be: mysql:host=127.0.0.1:3306;dbname=resq;charset=UTF8 + +preg_match('/^mysql:\/\/(.*):(.*)@(.*):(.*)\/(.*)\?(.*)/', $db_info, $result); + +$db_type = 'mysql:host='; +$user = $result[1]; +$pass = $result[2]; +$ip_port = $result[3] . ':' . $result[4] . ';'; +$db_name = 'dbname=' . $result[5] . ';'; +$charset = $result[6]; + +$dsn = $db_type . $ip_port . $db_name . $charset; + +//error_log($dsn); +//error_log($user); +//error_log($pass); // connect to db $db = new PDO($dsn, $user, $pass); @@ -13,33 +51,90 @@ $db = new PDO($dsn, $user, $pass); $sth = $db->prepare('insert into warranty_serial (id, sku, date_create, source, meta_info) values (:serial, :sku, :date_create, :source, :meta_info)'); // go through rows -$counter = 0; $source = 'motiv'; while (($row = fgetcsv($csv)) !== false) { - // skip first line - if ($counter == 0) + // TODO: verify if these are still the headers if there are headers + // possible lines in output file: + // (1) header in csv file + // SerialNumber,Sku,DispatchStatus,CreatedDate,InventoryStatus,CategoryID,CategoryName + // (2) No available data + // (3) CH2000012071,WCHD23BL-CPN00-LX,0,2020-08-11 04:05:27.090,0,4,CHAMPION MF + // (4) Empty line + // (5) empty sku + + // check if No available data + if ($row[0] == 'No available data') { - $counter++; + // skip the line + error_log('No available data, skipping the line...'); continue; } - /* - $serial = trim(strtoupper($row[0])); - $sku = trim($row[1]); - $date_create = $row[2]; - $ref_id = $row[3]; */ + // check if empty line + if ($row == array(null)) + { + // skip + error_log('Skipping empty line...'); + continue; + } + + // check if empty serial + if (empty($row[0])) + { + $err_message = "Empty serial. " . "\n"; + fwrite($output_fh, $err_message); + continue; + } // sample of line in output file: // serial number, sku, dispatch status, created date, inventory status, category id, category name // CH2000012071,WCHD23BL-CPN00-LX,0,2020-08-11 04:05:27.090,0,4,CHAMPION MF + // MG2000313690,N/A,1,2021-05-14T23:47:30.6430000+08:00,0,10,GOLD $serial = trim(strtoupper($row[0])); - $sku = trim($row[1]); + $sku = trim(strtoupper($row[1])); $dispatch_status = trim($row[2]); - $date_create = $row[3]; + $str_date_create = trim($row[3]); $inventory_status = trim($row[4]); $cat_id = trim($row[5]); - $cat_name = trim($row[6]); + $cat_name = trim(strtoupper($row[6])); + + error_log('Processing ' . $serial . ' and ' . $sku); + + // since some people cannot follow simple instructions... + // check the date format on the string + // try 2021-05-15T08:35:46+08:00 format on str_date_create + $date_create = DateTime::createFromFormat('Y-m-d\TH:i:sP', $str_date_create); + + if ($date_create == false) + { + // try this format: 2021-05-15T08:47:20.3330000+08:00 + // get the date, time and timezone from str_date_create + $str_date_time = substr($str_date_create, 0, 19); + $str_timezone = substr($str_date_create, 27); + $str_datetime_tz = $str_date_time . $str_timezone; + + // create DateTime object + // sample: 2021-05-15T12:16:06+08:00 + $date_create = DateTime::createFromFormat('Y-m-d\TH:i:sP', $str_datetime_tz); + + // check if datetime object was created + // if not, someone f*cked up and we have no date create + if ($date_create == false) + { + // log the serial + $message = "$serial - ERROR - " . "Invalid date format for create date." . "\n"; + fwrite($output_fh, $message); + continue; + } + } + + $created_date = $date_create->format('Y-m-d H:i:s'); + + //error_log($str_date_time); + //error_log($str_timezone); + //error_log($str_datetime_tz); + //error_log($date_create->format('Y-m-d H:i:s')); $meta_info = [ 'dispatch_status' => $dispatch_status, @@ -56,19 +151,27 @@ while (($row = fgetcsv($csv)) !== false) $res = $sth->execute([ ':serial' => $serial, ':sku' => $sku, - ':date_create' => $date_create, + ':date_create' => $created_date, ':source' => $source, ':meta_info' => $info, ]); if (!$res) { + // log the error $err = $sth->errorInfo(); - echo "Error ($serial) - " . $err[2] . "\n"; + $err_message = "$serial - ERROR - " . $err[2] . "\n"; + fwrite($output_fh, $err_message); + } + else + { + // log successful adding of serial + $message = "$serial - SUCCESS - " . "\n"; + fwrite($output_fh, $message); } } // close file fclose($csv); - +fclose($output_fh); diff --git a/utils/warranty_motiv_dev.sh b/utils/warranty_motiv_dev.sh index 00c73418..95f687d6 100755 --- a/utils/warranty_motiv_dev.sh +++ b/utils/warranty_motiv_dev.sh @@ -1,4 +1,4 @@ #!/bin/bash touch /tmp/warranty_download_serial.txt -/usr/bin/php /usr/share/nginx/html/resqapi/utils/get_warranty_serial/get_serials.php -/usr/bin/php /usr/share/nginx/html/resqapi/utils/load_warranty_serial/load_serials.php /tmp/warranty_download_serial.txt "mysql:host=localhost;dbname=resq;charset=UTF8" resq Motolite456 +/usr/bin/php /usr/share/nginx/html/resqapi/utils/get_warranty_serial/get_serials.php `date +%m-%d-%Y` +/usr/bin/php /usr/share/nginx/html/resqapi/utils/load_warranty_serial/load_serials.php /tmp/warranty_download_serial.txt "mysql:host=localhost;dbname=resq;charset=UTF8" diff --git a/utils/warranty_motiv_local.sh b/utils/warranty_motiv_local.sh new file mode 100755 index 00000000..e99c7f64 --- /dev/null +++ b/utils/warranty_motiv_local.sh @@ -0,0 +1,9 @@ +#!/bin/bash +#touch /tmp/warranty_download_serial.csv +proc_date=`date +%m-%d-%y -d "1 day ago"` +download_file="/tmp/warranty_download_serial_$proc_date.csv" +load_status_file="/tmp/warranty_load_status_$proc_date.txt" +echo $download_file +echo $load_status_file +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php $proc_date $download_file 1 +/usr/bin/php /var/www/resq/utils/load_warranty_serial/load_serials.php $download_file $load_status_file diff --git a/utils/warranty_motiv_local_bulk.sh b/utils/warranty_motiv_local_bulk.sh new file mode 100755 index 00000000..c4f2a551 --- /dev/null +++ b/utils/warranty_motiv_local_bulk.sh @@ -0,0 +1,40 @@ +#!/bin/bash +touch /tmp/warranty_download_serial.csv +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-03-21 /tmp/warranty_download_serial.csv 1 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-04-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-05-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-06-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-07-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-08-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-09-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-10-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-11-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-12-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-13-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-14-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-15-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-16-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-17-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-18-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-19-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-20-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-21-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-22-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-23-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-24-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-25-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-26-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-27-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-28-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-29-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-30-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-31-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-01-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-02-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-03-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-04-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-05-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-06-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-07-21 /tmp/warranty_download_serial.csv 0 +touch /tmp/warranty_load_status.txt +/usr/bin/php /var/www/resq/utils/load_warranty_serial/load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt diff --git a/utils/warranty_motiv_prod.sh b/utils/warranty_motiv_prod.sh index f13a7d7d..124f6e96 100755 --- a/utils/warranty_motiv_prod.sh +++ b/utils/warranty_motiv_prod.sh @@ -1,4 +1,9 @@ #!/bin/bash -touch /tmp/warranty_download_serial.txt -/usr/bin/php /var/www/resq/utils/get_warranty_serial/get_serials.php -/usr/bin/php /var/www/resq/utils/load_warranty_serial/load_serials.php /tmp/warranty_download_serial.txt "mysql:host=172.18.203.191:3306;dbname=resq;charset=UTF8" resq Motolite456 +proc_date=`date +%m-%d-%y -d "1 day ago"` +download_file="/tmp/warranty_download_serial_$proc_date.csv" +load_status_file="/tmp/warranty_load_status_$proc_date.txt" +#echo $download_file +#echo $load_status_file +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php $proc_date $download_file 1 +/usr/bin/php /var/www/resq/utils/load_warranty_serial/load_serials.php $download_file $load_status_file + diff --git a/utils/warranty_motiv_prod_bulk.sh b/utils/warranty_motiv_prod_bulk.sh new file mode 100755 index 00000000..c4f2a551 --- /dev/null +++ b/utils/warranty_motiv_prod_bulk.sh @@ -0,0 +1,40 @@ +#!/bin/bash +touch /tmp/warranty_download_serial.csv +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-03-21 /tmp/warranty_download_serial.csv 1 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-04-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-05-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-06-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-07-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-08-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-09-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-10-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-11-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-12-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-13-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-14-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-15-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-16-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-17-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-18-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-19-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-20-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-21-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-22-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-23-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-24-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-25-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-26-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-27-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-28-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-29-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-30-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 05-31-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-01-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-02-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-03-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-04-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-05-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-06-21 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-07-21 /tmp/warranty_download_serial.csv 0 +touch /tmp/warranty_load_status.txt +/usr/bin/php /var/www/resq/utils/load_warranty_serial/load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt