[php] UploadManualInvoice.php

Viewer

copydownloadembedprintName: UploadManualInvoice.php
  1. public function upload(Request $request, ManualInvoiceController $manualInvoiceController)
  2.     {
  3.         date_default_timezone_set("Asia/Bangkok");
  4.         $dateNow = date('Y-m-d H:i:s');            
  5.         $username_login     = session()->get('profile')['name'];
  6.  
  7.                 if ($request->input('sc_upload_manual') == "" || $request->input('sc_upload_manual') == "-" || $request->input('sc_upload_manual') == null || $request->input('sc_upload_manual') == '') {
  8.                         return redirect()->back()->with('alert_warning', 'Please select a service category!');
  9.                 }
  10.  
  11.         if ($request->file('file_upload_manual') == "" || $request->file('file_upload_manual') == "-" || $request->file('file_upload_manual') == null || $request->file('file_upload_manual') == '') {
  12.                         return redirect()->back()->with('alert_warning', 'Please upload file!');
  13.                 }
  14.  
  15.         $service_category   = $request->input('sc_upload_manual');
  16.         $File               = $request->file('file_upload_manual');
  17.                 $revenue_coa        = $request->input('sc_upload_manual');
  18.         $nameFileUpload     = $File->getClientOriginalName();
  19.         $nameFile                      = explode("_", $nameFileUpload);
  20.         $client_code       = $nameFile[0];
  21.         $month              = $nameFile[1];
  22.         $fake_year          = $nameFile[2];
  23.                 $fake                          = explode(".", $fake_year);
  24.                 $year                          = $fake[0];
  25.         $path_name          = Storage::put('/upload_manual_invoice', $File);
  26.         $results                       = Excel::selectSheetsByIndex(0)->load($File)->get();
  27.         $header                        = $results->getHeading(); //get xls's header
  28.             $extension          = $File->getClientOriginalExtension();
  29.         $size               = $File->getSize();
  30.         $path               = $File->getRealPath();
  31.         $username                       = session()->get('profile')['name'];
  32.  
  33.         // echo "</br></br> \n service_category : "; print_r($service_category) ; die();
  34.  
  35.         $arrClient = $manualInvoiceController->get_data_client_by_id($client_code);
  36.         if ($arrClient == null || $arrClient == '' || $arrClient == "") {
  37.             return redirect()->back()->with('alert_warning', 'Please Check Client Code Again. File Cannot be Executed.');
  38.         }
  39.  
  40.         $client_coas                           = $arrClient['client_coa'];
  41.         $client_code                           = $arrClient['client_code'];
  42.         $client_names                          = $arrClient['client_name'];
  43.         $client_domicile_address       = $arrClient['client_domicile_address'];
  44.         $no_spk                                    = $arrClient['client_no_spk'];
  45.         $no_addendum_spk                   = $arrClient['client_no_addendum_spk']; 
  46.         $materai_client                        = $arrClient['materai'];
  47.         $lmbg                                      = $arrClient['lmbnegara'];
  48.         $max_amount                            = $arrClient['max_amount'];
  49.         $invoice_rule                          = $arrClient['invoice_rule'];
  50.  
  51.         $uploads_manuals = [];
  52.  
  53.         $conn_am = DB::connection('account129');
  54.  
  55.         
  56.         if ($extension == "xlsx" || $extension == "xls") 
  57.         {
  58.             $datas = Excel::load($path)->get(); //load all of the data in sheet excel file
  59.             // return $datas;
  60.             // return count($datas);
  61.  
  62.             $headerRow = $datas->first()->keys()->toArray();
  63.  
  64.             $index = 0;
  65.  
  66.             $serialize = [];
  67.             $item_desc_temp = [];
  68.             $datasDivisi = [];
  69.             $rowsDiv = [];
  70.             $jmlhDiv = 0;
  71.             $arryDiv = 0;
  72.             $arryDivMin1 = 0;
  73.             $plusplus = 0;
  74.             $hx = 0;
  75.             $pic_name = '';
  76.             
  77.             // batas atas edit 26 april 2024 trace error upload manual invoice
  78.             
  79.             //$test_datas = $datas->transform(function ($value, $key) {
  80.               /*
  81.               echo $value;
  82.               $rowTest = $value->toArray();
  83.               $newArray = [];
  84.               foreach ($rowTest as $name => $rt) {
  85.                 if (!is_string($rt)) {
  86.                   continue;
  87.                 }
  88.                 $newArray[$name] = $rt;
  89.               }
  90.               $value->setItems($newArray);
  91.               return $value;
  92.               */
  93.               //return $value->reject(function ($value1, $key1) {
  94.                 //return !is_string($key1);
  95.               //});
  96.             //});
  97.             //$test_datas2 = $datas->getHeading();
  98.             //$test_datas3 = [];
  99.             /*
  100.             foreach ($test_datas2 as $vals) {
  101.               if ($vals == '') {
  102.                 continue;
  103.               }
  104.               $test_datas3[] = $vals;
  105.             }
  106.             $datas->setHeading($test_datas3);
  107.             //dd($datas);
  108.             // batas bawah edit 26 april 2024 trace error upload manual invoice
  109.             */
  110.             //// Menggabungkan & mengklasifikasikan dengan values Division
  111.             foreach ($datas as $vals) 
  112.             {
  113.                 $vals_div = $vals['divisi'];
  114.  
  115.                 if ( in_array($vals_div, $rowsDiv) ) {
  116.                     $checkDiv = array_keys($rowsDiv, $vals_div);
  117.                     $brsDiv = $checkDiv[0];
  118.                     $countdDatasDivisi = count($datasDivisi[$brsDiv]); 
  119.                     $datasDivisi[$brsDiv][$countdDatasDivisi] = $vals ;
  120.                 }
  121.                 else {
  122.                     array_push($rowsDiv,$vals_div);                    
  123.                     $checkDiv = array_keys($rowsDiv, $vals_div);
  124.                     $brsDiv = $checkDiv[0];
  125.                     $datasDivisi[$brsDiv][] = $vals ;
  126.                 }   
  127.             }
  128.             $item_description = array();
  129.             $serialize = [];
  130.             //// Men Serialize Data
  131.             for ($ij=0; $ij < count($datasDivisi) ; $ij++) 
  132.             {
  133.                 $division_name = '';
  134.                 $tot_traffict = 0;
  135.                 $sum_quantity = 0;
  136.                 $sum_uprice = 0;
  137.                 $sum_total = 0;
  138.                 $new_ppn = 0;
  139.                 $new_ppns = 0;
  140.  
  141.                 $cDataDivisi = count($datasDivisi[$ij]);  
  142.                 $arrClient = $manualInvoiceController->get_data_client_by_id($client_code);
  143.                 if ($arrClient == null || $arrClient == '' || $arrClient == "") return redirect()->back()->with('alert_warning', 'Please Check Client Code Again. File Cannot be Executed.');
  144.                 //// Menghitung TOtal Trafict tot_traffict
  145.                 for ($ih = 0; $ih < $cDataDivisi ; $ih++) 
  146.                 {
  147.  
  148.                     $division_name    = $datasDivisi[$ij][$ih]['divisi'];
  149.                     $produk           = $datasDivisi[$ij][$ih]['produk'];
  150.  
  151.                     if($service_category == '430000001') {$jenis_service = $datasDivisi[$ij][$ih]['jenis_layanan']; $service_code = 'W011'; } // for whatsapp
  152.                     else if($service_category == '4102004') { $jenis_service = $datasDivisi[$ij][$ih]['jenis_layanan']; } // for SMS Pull
  153.                     else if($service_category == '410000001') { $jenis_service = $datasDivisi[$ij][$ih]['jenis_layanan']; } // for SMS PUSH
  154.                     else if($service_category == '450000001') { $jenis_service = $datasDivisi[$ij][$ih]['jenis_layanan']; } // for Email PUSH
  155.                     else return redirect()->back()->with('alert_warning', 'Service Category Not Available. Please Check Service Category !!! ');
  156.  
  157.                     $countDatas = count($datasDivisi[$ij][$ih]);
  158.  
  159.                     if (isset($datasDivisi[$ij][$ih]['international'])) {
  160.                         $countDatasHeader = $countDatas;
  161.                     } else {
  162.                         $countDatasHeader = $countDatas-1;
  163.                     }
  164.  
  165.  
  166.                     for ($ik = 3; $ik < $countDatasHeader ; $ik++) {
  167.  
  168.                         $headers = [ucfirst($header[$ik])];
  169.                         $heads = $headers[0];
  170.                         $heads_lowers = strtolower($headers[0]);
  171.                         $qtty =  'qty_' . str_replace(" ","_", $heads);
  172.                         
  173.                         if($headers[0] != "") {
  174.                             $qtys = $datasDivisi[$ij][$ih][$heads_lowers];
  175.                             $contains_qtty = str_contains($qtys, '-');
  176.                             if($contains_qtty == true){
  177.                                 continue;
  178.                             }
  179.  
  180.                             if( $heads == 'Hutchinson' ) $tot_traffict = $tot_traffict + $qtys;
  181.                             if( $heads == 'Indosat' ) $tot_traffict = $tot_traffict + $qtys;
  182.                             if( $heads == 'Telkomsel' ) $tot_traffict = $tot_traffict + $qtys;
  183.                             if( $heads == 'Smartfren' ) $tot_traffict = $tot_traffict + $qtys;
  184.                             if( $heads == 'Excelcom' ) $tot_traffict = $tot_traffict + $qtys;
  185.                             if( $heads == 'Email Blast' ) $tot_traffict = $tot_traffict + $qtys;
  186.                             else $tot_traffict = $tot_traffict;                           
  187.                         }
  188.                     }
  189.                 }
  190.                 // End Menghitung TOtal Trafict tot_traffict
  191.                 
  192.                 // For generate itemdesc
  193.                 for ($ih = 0; $ih < $cDataDivisi ; $ih++) 
  194.                 {
  195.                     $division_name    = $datasDivisi[$ij][$ih]['divisi'];
  196.                     $produk           = $datasDivisi[$ij][$ih]['produk'];
  197.  
  198.                     if($service_category == '430000001') $jenis_service = $datasDivisi[$ij][$ih]['jenis_layanan']; // for whatsapp
  199.                     else if($service_category == '4102004') { $jenis_service = $datasDivisi[$ij][$ih]['jenis_layanan']; } // for SMS Pull
  200.                     else if($service_category == '410000001') $jenis_service = $datasDivisi[$ij][$ih]['jenis_layanan']; // for SMS PUSH
  201.                     else if($service_category == '450000001') { $jenis_service = $datasDivisi[$ij][$ih]['jenis_layanan']; } // for Email PUSH
  202.                     else return redirect()->back()->with('alert_warning', 'Service Category Not Available. Please Check Service Category !!! ');
  203.  
  204.                     if ($division_name == null || $division_name == '' || $division_name == "" || $division_name == "eof")  break;
  205.              
  206.                     $client_coas                = $arrClient['client_coa'];
  207.                     $client_code                = $arrClient['client_code'];
  208.                     $client_names               = $arrClient['client_name'];
  209.                     $client_domicile_address    = $arrClient['client_domicile_address'];
  210.                     $materai_client             = $arrClient['materai'];
  211.                     $lmbg                       = $arrClient['lmbnegara'];
  212.                     $max_amount                 = $arrClient['max_amount'];
  213.                     $invoice_rule               = $arrClient['invoice_rule'];
  214.  
  215.                     $countDatas = count($datasDivisi[$ij][$ih]);
  216.  
  217.                     if (isset($datasDivisi[$ij][$ih]['international'])) {
  218.                         $countDatasHeader = $countDatas;
  219.                     } else {
  220.                         $countDatasHeader = $countDatas-1;
  221.                     }
  222.                     
  223.                     for ($ik = 3; $ik < $countDatasHeader ; $ik++) 
  224.                     {
  225.                         $headers = [ucfirst($header[$ik])]; 
  226.  
  227.                         $heads = $headers[0];
  228.                         $qtty = explode("_",$heads);
  229.  
  230.                         $itemsName = ucwords(join(" ", $qtty));
  231.  
  232.                         $headsEmail = explode(" ", $itemsName);
  233.                         $email_blast = $headsEmail[0];
  234.                         $email_lower = lcfirst($email_blast);
  235.                         
  236.                         $heads_lowers = strtolower($headers[0]);
  237.  
  238.  
  239.                         if($jenis_service == "SMS Premium" && $heads != 'International') $itemsName = $heads . " Premium"; else $itemsName = $itemsName;
  240.                         
  241.                         $qtys = $datasDivisi[$ij][$ih][$heads_lowers];
  242.                         
  243.                         $contains = str_contains($qtys, '-');
  244.                         
  245.                         if($contains == true){
  246.                             $check = "true";
  247.                         }else{
  248.                             $check = "false";
  249.                         }
  250.  
  251.                         if( $check == "false"  )
  252.                         {
  253.                             $unitprice = 0;
  254.                             if ($service_category == '430000001') {
  255.                                 $getClientsPrice = $conn_am->select("Select a.*, b.service_name 
  256.                                                             FROM db_sprint_account.client_price AS a 
  257.                                                             LEFT JOIN `services` AS b ON a.service_code = b.service_code 
  258.                                                             WHERE a.client_code = '".$client_code."' AND b.service_name = '".$jenis_service."' AND a.provider_code = '".$itemsName."' LIMIT 1");
  259.                             } else if ($service_category == '450000001') {
  260.                                 $getClientsPrice = $conn_am->select("Select a.*, b.service_name 
  261.                                                             FROM db_sprint_account.client_price AS a 
  262.                                                             LEFT JOIN `services` AS b ON a.service_code = b.service_code 
  263.                                                             WHERE a.client_code = '".$client_code."' AND b.service_name = '".$email_blast."' AND a.provider_code = '".$email_blast."' LIMIT 1");
  264.                             } else {
  265.                                 $getClientsPrice = $conn_am->select("Select a.*, b.service_name 
  266.                                                             FROM db_sprint_account.client_price AS a 
  267.                                                             LEFT JOIN `services` AS b ON a.service_code = b.service_code 
  268.                                                             WHERE a.client_code = '".$client_code."' AND b.service_name = '".$jenis_service."' AND a.provider_code = '".$heads."' LIMIT 1");
  269.  
  270.                             }
  271.                            
  272.                             if( !empty($getClientsPrice) )
  273.                             {
  274.  
  275.                                 $prc_type   = $getClientsPrice[0]->price_type;
  276.                                 $hrgPrc     = $getClientsPrice[0]->price;
  277.                                 $arryPrice  = json_decode($hrgPrc);
  278.                                 $countPrice = count($arryPrice);
  279.                                 $vats       = $getClientsPrice[0]->vat;
  280.                             }
  281.                             else {
  282.                                 $prc_type   = 1;
  283.                                 $arryPrice  = [0];
  284.                                 $countPrice = count($arryPrice);
  285.                                 $vats       = 'exclude';
  286.                             }
  287.                 
  288.                                 if ($prc_type == 1)  $unitprice = $arryPrice[0];
  289.                                 else if ($prc_type == 2) $unitprice = round(($arryPrice[0] * $arryPrice[1] ));
  290.                                 else if ($prc_type == 3) {
  291.                                     for($p = 0; $p < $countPrice ; $p++) 
  292.                                     {
  293.                                         $trfct = intval($tot_traffict);
  294.  
  295.                                         $tr1 = intval($arryPrice[$p][0]);
  296.                                         $tr2 = intval($arryPrice[$p][1]);
  297.                                         $hrg = intval($arryPrice[$p][2]);
  298.                                         
  299.                                         if( $trfct >= $tr1 && $trfct <= $tr2 ) $unitprice = $hrg;
  300.                                         else {
  301.                                             if($unitprice > 0 ) $unitprice = $unitprice;
  302.                                             else $unitprice = 0;
  303.                                         }
  304.                                         
  305.                                     }
  306.                                 }
  307.  
  308.                                 
  309.                                 $tot_hrg = $unitprice * $qtys;
  310.                                 
  311.                                 $item_desc_temp[$ij][$ih][] = [     
  312.                                                                     "item_name" => $itemsName, 
  313.                                                                     "quantity" => $qtys, 
  314.                                                                     "unitprice" => $unitprice, 
  315.                                                                     "total" => $tot_hrg,
  316.                                                               ];
  317.                                 
  318.  
  319.                                 if($vats == 'exclude') $new_ppns = floor($tot_hrg * 0.11);
  320.                                 else $new_ppns = 0;
  321.  
  322.                                 $sum_quantity = $sum_quantity + $qtys;
  323.                                 $sum_uprice = $sum_uprice + $unitprice;
  324.  
  325.                                 $sum_total = $sum_total + $tot_hrg;
  326.                                 $new_ppn  = $new_ppn + $new_ppns;
  327.                         } else {
  328.                             continue;
  329.                         }
  330.  
  331.                     }
  332.                     $data_items[$ij][] = [
  333.                         "item"      => $produk,
  334.                         "item_desc" => $item_desc_temp[$ij][$ih]
  335.  
  336.                     ];
  337.  
  338.                 }
  339.  
  340.                 $json = [
  341.                             "detail" => [
  342.                                 "info"  => [
  343.                                     "from"         => "PT Sprint Asia",
  344.                                     "recipient"    => $client_names,
  345.                                     "reff_no"      => '',
  346.                                     "cust_id"      => '',
  347.                                     "sales_person" => ''
  348.                                 ],
  349.                                 "data"  => array($data_items[$ij]),
  350.                                 "total" => [
  351.                                     "quantity"  => $sum_quantity,
  352.                                     "unitprice" => $sum_uprice,
  353.                                     "sub_total" => ceil($sum_total),
  354.                                     "with_ppn"  => floor($new_ppn),
  355.                                     "with_pph"  => 0
  356.  
  357.                                 ]
  358.                             ],
  359.  
  360.                         ];
  361.  
  362.                 $serialize = json_encode($json);
  363.                 echo "division_name";
  364.                 // dd($division_name);
  365.                 $data_div           = $manualInvoiceController->get_data_division_by_name_and_client_code($division_name, $client_code);
  366.                 if ($data_div == null || $data_div == '' || $data_div == "") {
  367.                     return redirect()->back()->with('alert_warning', 'Please Check Data Divisi ' . $division_name .' Again. File Cannot be Executed.');
  368.                 }
  369.  
  370.                 //Division
  371.                 $division_names         = $data_div['division_name'];
  372.                 $division_code          = $data_div['division_code'];
  373.                 $bank_acc_number_sprint = $data_div['division_bank_acc_number_sprint'];
  374.                 $bank_acc_name_sprint   = $data_div['division_bank_acc_name_sprint'];
  375.                 $bank_coa_sprint        = $data_div['division_bank_coa_sprint'];
  376.                 $zahir_name             = $data_div['division_zahir_name'];
  377.                 $client_npwp_no         = $data_div['division_npwp'];
  378.                 $bank_acc_name_client   = $data_div['division_bank_account_name'];
  379.                 $bank_acc_number_client = $data_div['division_bank_account_number'];
  380.                 $bank_name              = $data_div['division_bank_name_sprint'];
  381.                 $client_coa             = $data_div['division_bank_name_sprint'];
  382.                 $division_address       = $data_div['division_address'];
  383.                 $division_invoice_rule  = $data_div['division_invoice_rule']; 
  384.                 $division_max_amount    = $data_div['division_max_amount'];
  385.                 $division_description   = $data_div['division_description'];
  386.                 $ba                     = $data_div['berita_acara'];
  387.                 if($ba == 1){$ba = "Yes";}else{$ba = "No";}
  388.                 $fp                     = $data_div['faktur_pajak'];
  389.                 if($fp == 1){$fp = "Yes";}else{$fp = "No";}
  390.                 $softcopy               = $data_div['soft_copy'];
  391.                 if($softcopy == 1){$softcopy = "Yes";}else{$softcopy = "No";}
  392.                 $hardcopy               = $data_div['hard_copy'];
  393.                 if($hardcopy == 1){$hardcopy = "Yes";}else{$hardcopy = "No";}
  394.                 
  395.                 $dept_code              = "$division_code-00";
  396.                 $data_dept              = $manualInvoiceController->get_data_dept_by_id($dept_code);
  397.                 
  398.                 if ($data_dept == null || $data_dept == '' || $data_dept == "") {
  399.                     return redirect()->back()->with('alert_warning', 'Please Check Data Department '.$dept_code.' Again. File Cannot be Executed.');
  400.                 }
  401.                 
  402.                 $dept_code = $data_dept['dept_code'];
  403.                 $dept_names = $data_dept['dept_name'];
  404.  
  405.                 //PIC 
  406.                 $data_pic      = $manualInvoiceController->get_data_pics_by_id($division_code);
  407.                
  408.                 if ($data_pic == null || $data_pic == '' || $data_pic == "") {
  409.                     return redirect()->back()->with('alert_warning', 'Please Check Data PIC from Division '.$division_code.'. File Cannot be Executed.');
  410.                 }
  411.  
  412.                 $pic_id       = $data_pic['pic_id'];
  413.                 $pic_name     = $data_pic['pic_name'];
  414.                 $email_client = $data_pic['pic_email'];
  415.                 $pic_position = $data_pic['pic_position'];
  416.  
  417.                 $data_pic_collection = $manualInvoiceController->get_data_pic_collection($division_code);
  418.  
  419.                 if ($data_pic_collection == null || $data_pic_collection == '' || $data_pic_collection == "") {
  420.                     $pic_collection_name        = "";
  421.                     $email_pic_collection       = $email_client;
  422.                 }
  423.                 else {
  424.                     if( !empty ($data_pic_collection['pic_name']) ) $pic_collection_name        = $data_pic_collection['pic_name'];
  425.                     else return redirect()->back()->with('alert_warning', 'Please Check pic_type_id at Pic Name ' . $division_name .' Again. File Cannot be Executed.');
  426.                     $email_pic_collection       = $data_pic_collection['pic_email'];
  427.  
  428.                 }
  429.  
  430.                 $data_pic_pph23 = $manualInvoiceController->get_data_pic_pph23($division_code);
  431.                 echo "</br></br> \n ~~~~~ data_pic_pph23 : "; print_r($data_pic_pph23) ; echo "~~~~~  </br> \n ";
  432.  
  433.                 if ($data_pic_pph23 == null || $data_pic_pph23 == '' || $data_pic_pph23 == "") {
  434.                     $pic_pph23_name        = "";
  435.                     $email_pic_pph23       = $email_client;
  436.                 }
  437.                 else {
  438.                     $pic_pph23_name        = $data_pic_pph23['pic_name'];
  439.                     $email_pic_pph23       = $data_pic_pph23['pic_email'];
  440.                 }
  441.  
  442.                 $sub_total = ceil($sum_total);
  443.                 $amount_invoice_rule = $sub_total + $new_ppn;
  444.                 
  445.                 if($new_ppn > 0){
  446.                     $vats = "exclude";
  447.                 }else if($new_ppn <= 0){
  448.                     $vats = "include";
  449.                 }
  450.                 
  451.                 //cek BUMN/Lembaga
  452.                 $real                   = $manualInvoiceController->real_field($lmbg, $invoice_rule, $max_amount, $amount_invoice_rule, $sub_total, $vats);
  453.  
  454.                 $sub_total_now          = $real[0];
  455.                 $sub_total_real         = $real[1];
  456.                 $new_ppn_now            = $real[2];
  457.                 $new_ppn_real           = $real[3];
  458.  
  459.                 $new_materai = 0;
  460.  
  461.                 if ($materai_client == 1) $new_materai = $manualInvoiceController->check_materai($sub_total_now, $new_ppn_now);
  462.                 else if ($materai_client     == 0) $new_materai = 0;
  463.  
  464.                 $pph23   = $manualInvoiceController->check_pph23($client_code, $sub_total_now);
  465.  
  466.                 $Total = round($sub_total_now + $new_ppn_now + $new_materai - $pph23);
  467.                 $Total_real = round($sub_total_real + $new_ppn_real + $new_materai - $pph23);
  468.                 $now = \Carbon\Carbon::now();
  469.                 $descManual = "-";
  470.                 
  471.                 if($materai_client == 1 ) $materai = "yes"; else $materai = "no";
  472.                 
  473.  
  474.                 $invXls[] = array(
  475.                     "client_code"               => $client_code,
  476.                     "client_name"               => $client_names,
  477.                     "division_code"             => $division_code,
  478.                     "division_name"             => $division_names,
  479.                     "division_description"      => $division_description,
  480.                     "dept_code"                 => $dept_code,
  481.                     "dept_name"                 => $dept_names,
  482.                     "pic_id"                    => $pic_id,
  483.                     "pic_name"                  => $pic_name,
  484.                     "pic_position"              => $pic_position,
  485.                     "inv_month"                 => $month,  //date("m"),
  486.                     "inv_year"                  => $year, //date("yy"),
  487.                     "unitprice"                 => $sum_uprice,
  488.                     "quantity"                  => $sum_quantity,
  489.                     "sub_total"                 => ceil($sub_total_now),
  490.                     "ppn"                       => floor($new_ppn_now),
  491.                     "sub_total_real"            => ceil($sub_total_real),
  492.                     "ppn_real"                  => floor($new_ppn_real),
  493.                     "materai"                   => $new_materai,
  494.                     "pph23"                     => $pph23,
  495.                     "total"                     => $Total,
  496.                     "total_real"                => $Total_real,
  497.                     "serialize_data"            => $serialize,
  498.                     "selisih"                   => 0,
  499.                     "status"                    => 0,
  500.                     "addmanual"                 => 2,
  501.                     "division_address"          => $division_address,
  502.                     "bank_acc_number_sprint"    => $bank_acc_number_sprint,
  503.                     "bank_acc_name_sprint"      => $bank_acc_name_sprint,
  504.                     "bank_acc_number_client"    => $bank_acc_number_client,
  505.                     "bank_acc_name_client"      => $bank_acc_name_client,
  506.                     "bank_coa_sprint"           => $bank_coa_sprint,
  507.                     "zahir_name"                => $zahir_name,
  508.                     "client_npwp_no"            => $client_npwp_no,
  509.                     "bank_name"                 => $bank_name,
  510.                     "client_coa"                => $client_coas,
  511.                     "revenue_coa"               => $revenue_coa,
  512.                     "email_client"              => $email_client,
  513.                     "email_collection"          => $email_pic_collection,
  514.                     "email_pph23"               => $email_pic_pph23,
  515.                     "description"               => $produk,
  516.                     "created_at"                => $now,
  517.                     "created_by"                => $username ." - Upload Manual Invoice",
  518.                     "id_collection"             =>'[""]',
  519.                     "ba"                        => $ba,
  520.                     "fp"                        => $fp,
  521.                     "softcopy"                  => $softcopy,
  522.                     "hardcopy"                  => $hardcopy
  523.  
  524.                 );
  525.  
  526.                 // return $invXls;
  527.             }
  528.             // END Men Serialize Data
  529.  
  530.             // return $invXls;
  531.             if (!empty($invXls)) {
  532.                 DB::table('db_sprint_ar.invoice')->insert($invXls);
  533.  
  534.                 
  535.                 $now                            = Carbon\Carbon::now('Asia/Jakarta');
  536.                 
  537.                 $saved_log_datas = preg_replace( "/\r|\n/", " ", json_encode($invXls) );
  538.                 $saved_log_datas = str_replace("\\", "", $saved_log_datas);
  539.                 DB::table('history')->insert([ 'client_name'=> $client_names, 'division_name'=> $division_names, 'dept_name'=> $dept_names, 'inp_desc2' => "Upload Manual Invoice, Clients Name : ".$client_names." , Divisions Name : ".$division_names." , Quantity : ".$sum_quantity. " , Description : ". $produk , 'inp_desc'=> $produk, 'activity'=> "Upload Manual Invoice", 'description'=> "Upload values : ". $saved_log_datas , 'created_by' => $username , 'created_at' => $now ]);
  540.                 
  541.             }
  542.             DB::commit();
  543.             $up_manualInvoice   = [
  544.                 "path_name" => $path_name,
  545.                 "file_name" => $nameFileUpload,
  546.                 "size"      => $size,
  547.                 "created_at"    => now()
  548.  
  549.             ];
  550.             $insert_upload_ = DB::table('upload_manual_invoice')->insert($up_manualInvoice);
  551.             return redirect()->back()->with('alert_import', 'Import file success');
  552.  
  553.         } 
  554.         else 
  555.         {
  556.             return redirect()->back()->with('alert_warning', 'Something wrong, excel only');
  557.         }
  558.                
  559.         }

Editor

You can edit this paste and save as new:


File Description
  • UploadManualInvoice.php
  • Paste Code
  • 10 May-2024
  • 29.25 Kb
You can Share it: