Esempio n. 1
0
 public function actionUpdatestatus()
 {
     $den_no = Yii::$app->request->post('den_no');
     $post = confirm::readconfirm(['D03_DEN_NO' => $den_no]);
     $post['D03_DEN_NO'] = $den_no;
     $post['status'] = Yii::$app->request->post('status');
     confirm::writeconfirm($post);
     $link = BaseUrl::base(true) . '/data/pdf/' . $den_no . '.pdf';
     return $link;
 }
Esempio n. 2
0
 public function actionIndex()
 {
     $api = new api();
     $uDenpyo = new Udenpyo();
     $cusObj = new Sdptd01customer();
     $login_info = Yii::$app->session->get('login_info');
     $cookie = \Yii::$app->request->cookies;
     // get info cus from cookie
     $cusInfo = $cookie->getValue('cus_info', ['type_redirect' => 3]);
     if ($cusInfo['type_redirect'] == 1) {
         if (count($cusObj->getData(['D01_KAIIN_CD' => $cusInfo['member_kaiinCd']])) == 0) {
             $dataInsert = $uDenpyo->convertKeyApiDB($cusInfo);
             $cusObj->setData($dataInsert);
             $cusObj->saveData();
         }
     }
     $custNo = (int) Yii::$app->request->get('custNo');
     $d03DenNo = Yii::$app->request->get('denpyo_no');
     $addCus = Yii::$app->request->get('addCust');
     $data['d03DenNo'] = $d03DenNo;
     if (Yii::$app->request->isPost && !$addCus) {
         $denpyoDataPost = [];
         $rs = $this->saveDataDenpyo($d03DenNo, $denpyoDataPost);
         if ($rs) {
             $this->saveCsv($denpyoDataPost);
             if (isset($denpyoDataPost['checkClickWarranty']) && $denpyoDataPost['checkClickWarranty'] == 1) {
                 $pdf = $this->savePdf($rs, $denpyoDataPost, false);
             }
             confirm::writeconfirm($denpyoDataPost);
             Yii::$app->session->setFlash('success', '作業伝票の登録が完了しました。');
             $this->redirect(\yii\helpers\BaseUrl::base(true) . '/detail-workslip?den_no=' . $rs);
         } elseif ($rs === 0) {
             if (!Yii::$app->request->get('addCust')) {
                 $data['notExitCus'] = true;
             }
         } else {
             $data['errorEditInsert'] = true;
         }
     }
     $carDefault = $uDenpyo->setDefaultDataObj('car');
     $denpyoComDefault = $uDenpyo->setDefaultDataObj('denpyoCom');
     $denpyo = $uDenpyo->setDefaultDataObj('denpyo');
     // set default data
     $tm01Sagyo = $uDenpyo->getTm01Sagyo([]);
     // Work job
     $data['totalDenpyoCom'] = 0;
     $listDenpyoCom = array_pad([], 10, $denpyoComDefault);
     $sagyoCheck = [];
     $data['listTm05Edit'] = [];
     $totalCarOfCus = 0;
     $data['csv'] = \backend\components\csv::readcsv(['D03_DEN_NO' => $d03DenNo]);
     $data['confirm'] = \backend\components\confirm::readconfirm(['D03_DEN_NO' => $d03DenNo]);
     if ($d03DenNo) {
         $denpyo = current($uDenpyo->getDenpyo(['D03_DEN_NO' => $d03DenNo]));
         $cusDb = $uDenpyo->getTd01Customer(['D01_CUST_NO' => $denpyo['D03_CUST_NO']]);
         if (count($cusDb)) {
             $cusInfo = current($cusDb);
             if (!$cusInfo['D01_KAIIN_CD']) {
                 $car = $uDenpyo->getCar($cusInfo['D01_CUST_NO']);
                 $totalCarOfCus = count($car);
                 $car = array_pad($car, 5, $carDefault);
             } else {
                 $uDenpyo->getInforCarCusFromApi($uDenpyo, $api, $carDefault, $cusInfo, $totalCarOfCus, $car, false);
             }
         } else {
             return false;
         }
         $tm01SagyoCheck = $uDenpyo->getDenpyoSagyo(['D04_DEN_NO' => $d03DenNo]);
         if (count($tm01SagyoCheck)) {
             foreach ($tm01SagyoCheck as $tmp) {
                 $sagyoCheck[] = $tmp['D04_SAGYO_NO'];
             }
         }
         $listDenpyoCom = $uDenpyo->getDenpyoCom(['D05_DEN_NO' => $d03DenNo]);
         if (count($listDenpyoCom)) {
             $arrCdCom = [];
             foreach ($listDenpyoCom as $tmp) {
                 $arrCdCom[] = $tmp['D05_COM_CD'];
             }
             $listTm05Edit = $uDenpyo->getTm05Com(['M05_COM_CD_IN' => $arrCdCom]);
             $arrTemp = [];
             foreach ($listTm05Edit as $tmp) {
                 $arrTemp[$tmp['M05_COM_CD']] = $tmp;
             }
             $data['listTm05Edit'] = $arrTemp;
         }
         $data['totalDenpyoCom'] = count($listDenpyoCom);
         $listDenpyoCom = array_pad($listDenpyoCom, 10, $denpyoComDefault);
     } else {
         if ($cusInfo['type_redirect'] == 1) {
             $uDenpyo->getInforCarCusFromApi($uDenpyo, $api, $carDefault, $cusInfo, $totalCarOfCus, $car);
             $cusInfo['type_redirect'] = 1;
         } else {
             if ($cusInfo['type_redirect'] == 3) {
                 $cusInfo = $uDenpyo->setDefaultDataObj('customer');
                 if ($custNo) {
                     $cusDb = $uDenpyo->getTd01Customer(['D01_CUST_NO' => $custNo]);
                     $cusInfo = current($cusDb);
                 }
                 $cusInfo['type_redirect'] = 3;
             }
             $car = $uDenpyo->getCar($custNo ? $custNo : (isset($cusInfo['D01_CUST_NO']) ? $cusInfo['D01_CUST_NO'] : 0));
             $totalCarOfCus = count($car);
             $car = array_pad($car, 5, $carDefault);
         }
     }
     $cusInfo['D01_SS_CD'] = $login_info['M50_SS_CD'];
     $data['sagyoCheck'] = $sagyoCheck;
     $ssUser = ['' => ''];
     $ssUserDenpyo = ['' => ''];
     $tm08Sagyosya = $uDenpyo->getTm08Sagyosya(['M08_SS_CD' => $d03DenNo ? $denpyo['D03_SS_CD'] : $login_info['M50_SS_CD']]);
     // 277426 Is login
     if (count($tm08Sagyosya)) {
         foreach ($tm08Sagyosya as $tmp) {
             $ssUser[$tmp['M08_JYUG_CD']] = $tmp['M08_NAME_SEI'] . $tmp['M08_NAME_MEI'];
             $ssUserDenpyo[$tmp['M08_NAME_SEI'] . '[]' . $tmp['M08_NAME_MEI']] = $tmp['M08_NAME_SEI'] . $tmp['M08_NAME_MEI'];
         }
     }
     $data['pagination'] = new Pagination(['totalCount' => $uDenpyo->countDataRecord('tm05Com', []), 'defaultPageSize' => 10]);
     $data['filters']['limit'] = $data['pagination']->limit;
     $data['filters']['offset'] = $data['pagination']->offset;
     $data['tm05Com'] = $uDenpyo->getTm05Com($data['filters']);
     $data['cus'] = $cusInfo;
     $data['totalCarOfCus'] = $totalCarOfCus;
     $data['car'] = $car;
     $data['denpyo'] = $denpyo;
     $data['ssUer'] = $ssUser;
     $data['ssUerDenpyo'] = $ssUserDenpyo;
     $data['tm01Sagyo'] = $tm01Sagyo;
     $data['listDenpyoCom'] = $listDenpyoCom;
     $data['item'] = Yii::$app->params['items'];
     $data['car_places'] = [];
     $data['car_regions'] = Yii::$app->params['car_regions'];
     $data['url_car_api'] = Yii::$app->params['api']['car']['url_car'];
     foreach (Yii::$app->params['car_regions'] as $region => $prefectures) {
         foreach ($prefectures as $prefecture => $_places) {
             $data['car_places'][$prefecture] = $_places;
         }
     }
     \Yii::$app->view->title = '作業伝票作成';
     \Yii::$app->params['titlePage'] = '作業伝票作成';
     return $this->render('index', $data);
 }