public function setData($data = [], &$id = null) { $login_info = Yii::$app->session->get('login_info'); $data['D01_UPD_USER_ID'] = $login_info['M50_USER_ID']; if ($id) { $obj = static::findOne($id); } else { $obj = new Sdptd01customer(); $data['D01_CUST_NO'] = $obj->getSeq(); $data['D01_TAISYO'] = 1; $id = $data['D01_CUST_NO']; $obj->D01_INP_DATE = new Expression("CURRENT_DATE"); $data['D01_INP_USER_ID'] = $login_info['M50_USER_ID']; } $obj->attributes = $data; foreach ($obj->attributes as $k => $v) { if ($k != 'D01_UPD_DATE' && $k != 'D01_INP_DATE') { $obj->{$k} = trim($v) != '' ? trim($v) : null; } } $obj->D01_UPD_DATE = new Expression("CURRENT_DATE"); $this->obj = $obj; }
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); }
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); }
/** * @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; }
/** * @inheritdoc * check card info * @author: dangbc6591 */ public function actionCheckcard() { utilities::deleteCookie('cus_info'); //Delete coolkie cus_info $flag = false; //Get data post $url_redirect = Yii::$app->request->post('url_redirect'); $type_redirect = 2; //Yii::$app->request->post('type_redirect'); $member_card = Yii::$app->request->post('card_number_auth'); $customer = new Sdptd01customer(); $member_info = $customer->getData(['D01_KAKE_CARD_NO' => $member_card]); if (count($member_info) == 1) { $member_info = $member_info[0]; $member_info['type_redirect'] = $type_redirect; $cookie = new Cookie(['name' => 'cus_info', 'value' => $member_info]); \Yii::$app->getResponse()->getCookies()->add($cookie); $flag = true; } Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return $flag; }