Example #1
0
 /**
  * test api
  * @author: Dang Bui
  */
 public function actionTestapi()
 {
     $api = new api();
     $memem = $api->getInfoCardTop('4035607000500000');
     $member_info = $api->getMemberInfo($memem['member_kaiinCd']);
     $infocard = $api->getInfoListCard($memem['member_kaiinCd']);
     echo '<pre>';
     var_dump($memem);
     var_dump($member_info);
     var_dump($infocard);
     echo '</pre>';
     die;
 }
Example #2
0
 /**
  * @return array
  */
 public function actionCus()
 {
     $api = new api();
     $cusObj = new \app\models\Sdptd01customer();
     $request = Yii::$app->request;
     $cookie = \Yii::$app->request->cookies;
     $cusInfo = $cookie->getValue('cus_info', ['type_redirect' => 3]);
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $data = Yii::$app->request->post();
     $cusDd = [];
     if ($data['D01_KAKE_CARD_NO']) {
         $cusDd = $cusObj->getData(['D01_KAKE_CARD_NO' => $data['D01_KAKE_CARD_NO']]);
     }
     $usappyId = $request->post('D01_KAIIN_CD');
     $check = count($cusDd);
     if ($data['D01_KAKE_CARD_NO'] != '' && $check > 0) {
         $cusDb = current($cusDd);
         if ($cusDb['D01_KAIIN_CD'] != $usappyId) {
             $result = ['kake_card_no_exist' => '1'];
             return $result;
         }
         if ($cusInfo['type_redirect'] == 2 && $check > 1) {
             $result = ['kake_card_no_exist' => '1'];
             return $result;
         }
         if ($cusInfo['type_redirect'] == 3 && $check > 0) {
             if (!$data['D01_CUST_NO']) {
                 $result = ['kake_card_no_exist' => '1'];
                 return $result;
             }
         }
         if ($check > 1) {
             $result = ['kake_card_no_exist' => '1'];
             return $result;
         }
     }
     if ($check == 1 && isset($data['D01_CUST_NO']) && $data['D01_CUST_NO']) {
         if ($cusDd[0]['D01_CUST_NO'] != $data['D01_CUST_NO']) {
             $result = ['kake_card_no_exist' => '1'];
             return $result;
         }
     }
     if ($cusInfo['type_redirect'] == 1) {
         // Is member
         $dataCsApi = ['member_kaiinName' => $request->post('D01_CUST_NAMEN'), 'member_kaiinKana' => $request->post('D01_CUST_NAMEK'), 'member_telNo1' => $request->post('D01_TEL_NO'), 'member_telNo2' => $request->post('D01_MOBTEL_NO'), 'member_address' => $request->post('D01_ADDR'), 'member_yuubinBangou' => $request->post('D01_YUBIN_BANGO')];
         $res = $api->updateMemberBasic($usappyId, $dataCsApi);
         $resDb = 1;
         $cusDb = $cusObj->getData(['D01_KAIIN_CD' => $usappyId]);
         if (count($cusDb)) {
             $dataDb = ['D01_NOTE' => $request->post('D01_NOTE'), 'D01_KAKE_CARD_NO' => $request->post('D01_KAKE_CARD_NO')];
             $cusObj->setData($dataDb, $cusDb['0']['D01_CUST_NO']);
             $resDb = (int) $cusObj->saveData();
         }
         $memberInfo = $api->getMemberInfo($usappyId);
         $memberInfo['type_redirect'] = 1;
         $result = ['result_api' => (int) $res, 'result_db' => $resDb, 'custNo' => 0];
     } else {
         $cusObj->setData($data, $data['D01_CUST_NO']);
         $res = $cusObj->saveData();
         $memberInfo = $cusObj->getData(['D01_CUST_NO' => $data['D01_CUST_NO']]);
         $memberInfo['type_redirect'] = 3;
         $result = ['result_db' => $res, 'result_api' => 1, 'custNo' => $data['D01_CUST_NO']];
     }
     $cookie = new Cookie(['name' => 'cus_info', 'value' => $memberInfo]);
     \Yii::$app->response->cookies->add($cookie);
     return $result;
 }
Example #3
0
 public function actionPreview()
 {
     $branch = utilities::getAllBranch();
     $ss = $branch['all_ss'];
     $address = $branch['ss_address'];
     $tel = $branch['ss_tel'];
     $api = new api();
     $data = [];
     $filter['detail_no'] = Yii::$app->request->get('den_no');
     $cus = new Sdptd01customer();
     $obj = new Sdptd03denpyo();
     $obj_job = new Sdptm01sagyo();
     $car = new Sdptd02car();
     $job[''] = '';
     $all_job = $obj_job->getData();
     foreach ($all_job as $k => $v) {
         $job[$v['M01_SAGYO_NO']] = $v['M01_SAGYO_NAMEN'];
     }
     $detail = $obj->getDataSearch($filter);
     if (empty($detail)) {
         $this->redirect(BaseUrl::base(true) . '/list-workslip');
     }
     $data['detail'] = $detail[0];
     $data['detail']['D02_SYAKEN_CYCLE'] = $this->getCar(['D02_CUST_NO' => $data['detail']['D03_CUST_NO'], 'D02_CAR_NO' => $data['detail']['D03_CAR_NO']]);
     //getCustomer_API
     $cus_info = $cus->findOne($data['detail']['D03_CUST_NO']);
     $data['detail']['D01_UKE_TAN_NAMEN'] = $cus_info['D01_UKE_TAN_NAMEN'];
     if (isset($cus_info['D01_KAIIN_CD'])) {
         $info = $api->getMemberInfo($cus_info['D01_KAIIN_CD']);
         $data['detail']['D01_CUST_NAMEN'] = $info['member_kaiinName'];
         $data['detail']['D01_CUST_NAMEK'] = $info['member_kaiinKana'];
     }
     //getCar_API
     if ($cus_info['D01_KAIIN_CD'] != '') {
         $car_api = $api->getInfoListCar($cus_info['D01_KAIIN_CD']);
         foreach ($car_api['car_carSeq'] as $k => $v) {
             if ($v == $data['detail']['D03_CAR_SEQ']) {
                 $data['detail']['D02_SYAKEN_CYCLE'] = $car_api['car_syakenCycle'][$k];
             }
         }
     }
     $data['ss'] = isset($ss[$data['detail']['D03_SS_CD']]) ? $ss[$data['detail']['D03_SS_CD']] : '';
     $data['address'] = isset($address[$data['detail']['D03_SS_CD']]) ? $address[$data['detail']['D03_SS_CD']] : '';
     $data['tel'] = isset($tel[$data['detail']['D03_SS_CD']]) ? $tel[$data['detail']['D03_SS_CD']] : '';
     $data['detail']['sagyo'] = $this->getSagyo($data['detail']['D03_DEN_NO']);
     $data['detail']['product'] = $this->getProduct($data['detail']['D03_DEN_NO']);
     $data['job'] = $job;
     $data['status'] = Yii::$app->params['status'];
     $data['csv'] = csv::readcsv(['D03_DEN_NO' => $filter['detail_no']]);
     $data['confirm'] = confirm::readconfirm(['D03_DEN_NO' => $filter['detail_no']]);
     $this->layout = '@app/views/layouts/print';
     Yii::$app->view->title = '作業確認書';
     Yii::$app->params['titlePage'] = '作業確認書';
     return $this->render('preview', $data);
 }
Example #4
0
 /**
  * @inheritdoc
  * check member usappy info
  * @author: dangbc6591
  */
 public function actionCheckmember()
 {
     utilities::deleteCookie('cus_info');
     //Delete coolkie cus_info
     $api = new api();
     $flag = false;
     $flag1 = false;
     $flag2 = true;
     $flag3 = false;
     $array_source = [];
     //Get data post
     $url_redirect = Yii::$app->request->post('url_redirect');
     $type_redirect = 1;
     //Yii::$app->request->post('type_redirect');
     $member_card = Yii::$app->request->post('card_number', '');
     $member_birthday = Yii::$app->request->post('member_birthday', '');
     $member_kaiinKana = preg_replace(['/\\s/', '/\\s+/'], '', Yii::$app->request->post('member_kaiinKana', ''));
     $member_tel = Yii::$app->request->post('member_tel', '');
     $license_plates = Yii::$app->request->post('license_plates', '');
     if ($member_birthday != '') {
         $array_source['member_birthday'] = $member_birthday;
     }
     if ($member_kaiinKana != '') {
         $array_source['member_kaiinKana'] = $member_kaiinKana;
     }
     if ($member_tel != '') {
         $array_source['member_tel'] = $member_tel;
     }
     if ($license_plates != '') {
         $array_source['license_plates'] = $license_plates;
     }
     $member_info = $api->getInfoCardTop($member_card);
     $member_info['type_redirect'] = $type_redirect;
     if (!isset($member_info['member_kaiinCd'])) {
         $flag = false;
     } else {
         $member_info['member_kaiinKana'] = preg_replace(['/\\s/', '/\\s+/'], '', $member_info['member_kaiinKana']);
         //trim whitespace in kaiinKana
         $flag1 = $this->equalArray($array_source, $member_info);
         if ($license_plates != '') {
             if ($list_info_car = $api->getInfoListCar($member_info['member_kaiinCd'])) {
                 $car_carNo = $list_info_car['car_carNo'];
                 $flag2 = $this->equalNocar($license_plates, $car_carNo);
             } else {
                 $flag2 = false;
             }
         }
         $member_api = $api->getMemberInfo($member_info['member_kaiinCd']);
         $member_info = $member_info + $member_api;
         if (isset($member_info['member_kaiinCd'])) {
             $flag3 = true;
         }
     }
     if ($flag1 == true && $flag2 == true && $flag3 == true) {
         $cookie = new Cookie(['name' => 'cus_info', 'value' => $member_info]);
         Yii::$app->response->cookies->add($cookie);
         $flag = true;
     }
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return $flag;
 }