Esempio n. 1
0
 public function post_uploadsetoran()
 {
     Input::upload('datasetoran', path('public'), 'upload.xlsx');
     $objPHPExcel = new PHPExcel();
     $objPHPExcel = PHPExcel_IOFactory::load(path('public') . 'upload.xlsx');
     $arrayst = array(1 => 7, 2 => 8, 3 => 9, 4 => 19, 5 => 12, 6 => 11, 7 => 16, 8 => 17, 9 => 13, 10 => 14, 11 => 21, 12 => 15, 13 => 10, 20 => 20);
     $startline = 8;
     foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
         $worksheetTitle = $worksheet->getTitle();
         $highestRow = $worksheet->getHighestRow();
         // e.g. 10
         $highestColumn = $worksheet->getHighestColumn();
         // e.g 'F'
         $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
         $nrColumns = ord($highestColumn) - 64;
         echo "<br>The worksheet " . $worksheetTitle . " has ";
         echo $nrColumns . ' columns (A-' . $highestColumn . ') ';
         echo ' and ' . $highestRow . ' row.';
         echo '<br>Data: <table border="1"><tr>';
         for ($row = $startline; $row <= $highestRow; ++$row) {
             $cell = $worksheet->getCellByColumnAndRow(1, $row);
             $val = $cell->getValue();
             $checkin = Checkin::find($val);
             if ($checkin) {
                 foreach ($arrayst as $financial_type_id => $cellinexcell) {
                     $cell = $worksheet->getCellByColumnAndRow($cellinexcell, $row);
                     $val = $cell->getValue();
                     $payment = Checkinfinancial::where_checkin_id($checkin->id)->where_financial_type_id($financial_type_id)->first();
                     if ($payment) {
                         $payment->amount = $val;
                         $payment->save();
                     } else {
                         $payment = Checkinfinancial::create(array('checkin_id' => $checkin->id, 'financial_type_id' => $financial_type_id, 'amount' => $val));
                     }
                 }
                 echo '<tr>';
                 for ($col = 0; $col < $highestColumnIndex; ++$col) {
                     echo '<td>' . $val . ' ' . $col . '</td>';
                 }
                 echo '</tr>';
             }
         }
         echo '</table>';
     }
 }
Esempio n. 2
0
 public function post_afterpaysave()
 {
     Log::write('info', Request::ip() . ' User : '******' Event: Save Edit Setoran', true);
     $jsondata = Input::json();
     //lihat KS
     $tabungan_pengemudi = 0;
     $ks_pengemudi = 0;
     if ((int) $jsondata->ks > 0) {
         $tabungan_pengemudi = (int) $jsondata->ks;
     } else {
         $ks_pengemudi = abs((int) $jsondata->ks);
     }
     $setoran = array();
     $setoran['1'] = (int) $jsondata->setoran_wajib;
     $setoran['2'] = (int) $jsondata->tab_sp;
     $setoran['3'] = (int) $jsondata->denda;
     $setoran['4'] = (int) $jsondata->pot;
     $setoran['5'] = (int) $jsondata->tag_spart;
     $setoran['6'] = (int) $jsondata->tag_ks;
     $setoran['7'] = (int) $jsondata->biaya_tc;
     $setoran['8'] = (int) $jsondata->iuran_laka;
     $setoran['9'] = (int) $jsondata->tag_cicilan_dp;
     $setoran['10'] = (int) $jsondata->tag_hut_lama;
     $setoran['11'] = (int) $ks_pengemudi;
     $setoran['12'] = (int) $jsondata->tag_other;
     $setoran['13'] = (int) $jsondata->tag_dp_spart;
     $setoran['20'] = (int) $jsondata->setoran_cash;
     $setoran['21'] = (int) $tabungan_pengemudi;
     //Edit Status Operasi
     //End Status Operasi
     try {
         foreach ($setoran as $key => $value) {
             /*
                           $payment = Checkinfinancial::create(array(
             'checkin_id'=>$jsondata->checkin_id, 
             'financial_type_id'=> $key, 
             'amount'=> $value));
             */
             $payment = Checkinfinancial::where_checkin_id($jsondata->checkin_id)->where_financial_type_id($key)->first();
             if ($payment) {
                 $payment->amount = $value;
                 $payment->save();
             } else {
                 $payment = Checkinfinancial::create(array('checkin_id' => $jsondata->checkin_id, 'financial_type_id' => $key, 'amount' => $value));
             }
         }
         $checkin = Checkin::find($jsondata->checkin_id);
         $checkin->checkin_step_id = 3;
         $checkin->operasi_status_id = $jsondata->operasi_status_id;
         $checkin->shift_id = $jsondata->shift_id;
         $checkin->save();
         /*
                     if($setoran['11'] > 0)
                     {
                       Blocked::create(array(
                                           'driver_id'=> $checkin->driver_id, 
                                           'fleet_id' => $checkin->fleet_id , 
                                           'blocked_status_id' => 1,
                                           'checkin_id' => $checkin->id,  
                                           'date'=> date('Y-m-d H:i:s') ));
         
                       $block = Driver::find($checkin->driver_id);
                       $block->fg_blocked = 1;
                       $block->save();
                     }*/
         //update status checkin
         /*
         $pothutanglama = Driverfinancial::where_driver_id($checkin->driver_id)->where_financial_type_id(18)->first();
         if($pothutanglama){
           $pothutanglama->amount = $pothutanglama->amount -  $jsondata->tag_hut_lama; 
         }
         
         $tabunganpengemudi = Driverfinancial::where_driver_id($checkin->driver_id)->where_financial_type_id(21)->first();
         if($tabunganpengemudi){
           $tabunganpengemudi->amount = $tabunganpengemudi->amount + $tabungan_pengemudi; 
         }else{
           Driverfinancial::create(array(
                           'driver_id'=> $checkin->driver_id,
                           'financial_type_id' => 21,
                           'amount' => $tabungan_pengemudi,
                           ));
         }
         
         $ks = Kewajiban::where_fleet_id($checkin->fleet_id)
                         ->where_driver_id($checkin->driver_id)
                         ->where_financial_type_id(6)->first();
         if($ks){
           $ks->total_amount = ($ks->total_amount + $setoran['11'])  - $setoran['6'];
         }else{
           Kewajiban::create(array(
                 'fleet_id' => $checkin->fleet_id,
                 'driver_id' => $checkin->driver_id,
                 'financial_type_id' => 6,
                 'amount' => 0,
                 'total_amount' => $setoran['11'],
             ));
         }
         
         
         
         if((int)$jsondata->denda > 10000)
         {
           Blocked::create(array(
                               'driver_id'=>$checkin->driver_id, 
                               'fleet_id' => $checkin->fleet_id , 
                               'blocked_status_id' => 6,
                               'checkin_id' => $checkin->id,  
                               'date'=> date('Y-m-d H:i:s') ));
         
           $block = Driver::find($checkin->driver_id);
           $block->fg_blocked = 1;
           $block->save();
         }
         */
         return json_encode(array('msg' => 'Setoran berhasil di ubah'));
     } catch (Exception $e) {
         return json_encode(array('msg' => 'Edit Setoran Gagal'));
     }
 }