Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
This uploader supports multiple file upload.
Submit
~
var
www
podio.norlys.foo
httpdocs
app
Http
Controllers
File Content:
orderFallbackController.php
<?php namespace App\Http\Controllers; use App\Repositories\Podio\PodioServices; use App\Repositories\Telia\TeliaServices; use Illuminate\Support\Facades\DB; use PodioAuth\Controllers\PodioAuth; use PodioAuth\Repositories\Podio; use App\Orders; class orderFallbackController extends Controller { public function sync(){ try{ $orders = DB::table('orders') ->whereRaw("JSON_LENGTH(customer) = 1") ->where('podio_id', '!=', '') ->get(); $allIds = []; foreach($orders as $order){ $ord = json_decode($order->customer); if($ord->item_id != ''){ $ids = []; $ids['customer_id'] = $ord->item_id; $ids['row_id'] = $order->id; $allIds[] = $ids; } } if (PodioAuth::podioAppAuthWithName('customers')) { foreach($allIds as $aid){ $config = config('podio'); $appFields = $config['app_auth']['customers']['app_fields']; $customer = Podio::PodioItem_get($aid['customer_id']); $customerInfo = []; $customerInfo['item_id'] = $aid['customer_id']; foreach ($customer['fields'] as $customerField) { switch ($customerField['external_id']) { case $appFields['name']['ext_id']: $customerInfo['name'] = $customerField['values'][0]['value']; break; case $appFields['contact_number']['ext_id']: $customerInfo['contact_number'] = $customerField['values'][0]['value']; break; case $appFields['email']['ext_id']: $customerInfo['email'] = $customerField['values'][0]['value']; break; } } $customerData = json_encode($customerInfo); $order = Orders::find($aid['row_id']); if ($order) { $order->customer = $customerData; $order->save(); } } } }catch(\Exception $e){ print_r($e); exit; } } public function syncBackup() { exit; ini_set('memory_limit', '-1'); // exit; //podio-bpm-integration-qyz2lm //mGmDUDcSZvouKHsq5hIdCR5EaiMtBY1qhaCZmsu5ZQOgxSgkF9mySXDBKOWuUFIU $success = ''; $failed = ''; $getOrdersFile = storage_path('orders') . '/updated_order_2022.xlsx'; $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx"); $spreadsheet = $reader->load($getOrdersFile); $worksheet = $spreadsheet->getActiveSheet(); $rows = $worksheet->toArray(); array_shift($rows); $arr = array(); foreach ($rows as $key => $item) { $arr[$item[1]][$key] = $item; } ksort($arr, SORT_NUMERIC); foreach ($arr as $mutipleRow) { $finalArray = NULL; $handset = ''; $subscription = ''; $existingHand = []; $existingSub = []; foreach ($mutipleRow as $row) { switch ($row[17]) { case 'Handset': if (!in_array($row[16], $existingHand)) { $handset .= '{ "handsetName":"' . $row[16] . '" },'; } $existingHand[] = $row[16]; break; case 'Subscription': if (!in_array($row[16], $existingSub)) { $subscription .= '{ "subscriptionType":"' . $row[16] . '", "isNumberPorting":"' . strtolower($row[18]) . '" },'; } $existingSub[] = $row[16]; break; } $finalArray = $row; } $data = ''; if ($handset != '') { $data .= '"handsetInfo":[ ' . trim($handset, ',') . ' ]'; } if ($subscription != '') { if ($handset != '') { $data .= ',"subscriptionInfo":[ ' . trim($subscription, ',') . ' ]'; } else { $data .= '"subscriptionInfo":[ ' . trim($subscription, ',') . ' ]'; } } //Format send time $sendTimeStamp = \DateTime::createFromFormat('d-M-y H.i.s.u A', $finalArray[7]); $sendTimeStamp = date("Y-m-d H:i:s", $sendTimeStamp->getTimestamp()); //Format Approve Date if (strlen($finalArray[10]) > 1) { $divaApproveDate = \DateTime::createFromFormat('d-m-y H:i:s.u A', $finalArray[10]); $divaApproveDate = date("Y-m-d H:i:s", $divaApproveDate->getTimestamp()); } else { $divaApproveDate = ""; } //Format Created Date $orderCreatedDate = \DateTime::createFromFormat('d-m-y H:i:s.u A', $finalArray[9]); $orderCreatedDate = date("Y-m-d", $orderCreatedDate->getTimestamp()); $orderStatus = ""; switch ($row[8]) { case 'Order Validation in Progress': $orderStatus = 'Order confirmed by Customer'; break; case 'Data Missing': $orderStatus = ""; break; case 'Order Part Processing': $orderStatus = 'Order confirmed by Customer'; break; case 'Credit Check Failed': $orderStatus = 'Order confirmed by Customer'; break; case 'Order Processing Send Logistics': $orderStatus = 'Order confirmed by Customer'; break; case 'Rejected by Customer': $orderStatus = 'Rejected by Customer'; break; case 'Order Completed': $orderStatus = 'Order confirmed by Customer'; break; case 'Awaiting Customer Confirmation': $orderStatus = 'Awaiting Customer Confirmation'; break; } if ($orderStatus != "") { $prepareData = '{ "bpmHeader":{ "transactionId": "' . $finalArray[0] . '", "callerReferenceId":"' . $finalArray[1] . '", "callerId":"' . $finalArray[4] . '", "communication":"' . $finalArray[6] . '", "logistics":"' . $finalArray[5] . '", "channel":"' . $finalArray[3] . '", "brand":"' . $finalArray[2] . '", "sendTimeStamp":"' . $sendTimeStamp . '" }, "customerInfo":{ "customerName":"' . $finalArray[15] . '", "contactNumber":"' . $finalArray[14] . '", "contactEmail":"' . $finalArray[13] . '" }, "divaInfo":{ "divaLinkSentDate":"", "divaLinkResendDate":"", "divaLinkApproveDate":"' . $divaApproveDate . '" }, "resellerInfo":{ "dealer":"' . $finalArray[11] . '", "salesAgent":"' . $finalArray[12] . '" }, "orderInfo":{ "orderCreatedDate":"' . $orderCreatedDate . '", "orderStatus":"' . $orderStatus . '" }, "productListInfo":{ ' . $data . ' } } '; try { if (PodioServices::getAndUpdateOrderFromBPMFallback($prepareData)) { $success .= $finalArray[1] . '<br>'; } else { $failed .= $finalArray[1] . '<br>'; } } catch (Exception $e) { } } } echo 'SUCCESS<br>' . $success; echo 'FAILED<br>' . $failed; } }
Edit
Download
Unzip
Chmod
Delete