You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

902 lines
59 KiB

  1. <?php
  2. use backend\modules\motorcade\assets\motorcadeUIAsset;
  3. use backend\modules\motorcade\models\BusOrder;
  4. use yii\helpers\Html;
  5. use backend\modules\motorcade\models\BusOrderStatusLog;
  6. use backend\modules\motorcade\models\RunBusExpenses;
  7. use backend\modules\motorcade\models\BusItinerary;
  8. use common\models\BaseSupplier;
  9. use kartik\grid\GridView;
  10. use yii\widgets\Pjax;
  11. use common\components\zActiveForm;
  12. use yii\helpers\ArrayHelper;
  13. /* @var $this yii\web\View */
  14. /* @var $model BusOrder */
  15. /* @var $data array */
  16. #endregion
  17. motorcadeUIAsset::addScript($this, '/js/motorcade.js');
  18. motorcadeUIAsset::addScript($this, '/js/add_car.js?v=0.0.1');
  19. motorcadeUIAsset::addScript($this, '/js/detail.js?v=' . time());
  20. $this->title = $model->id;
  21. $this->params['breadcrumbs'][] = ['label' => 'Bus Orders', 'url' => ['index']];
  22. $this->params['breadcrumbs'][] = $this->title;
  23. $this->registerJs('var initFlag = false;', $this::POS_BEGIN);
  24. $this->registerJs('$(".dynamicform_wrapper").on("afterInsert", function(e, item) {
  25. $(item).find(\'.timepicker_box input\').val(\'00:00\').prop(\'disabled\', false);
  26. z.timePicker();
  27. });');
  28. $cancel = $model->run_status != '439';
  29. $single_arr = $data['bus_depart']['single'];
  30. $str = implode(',', $single_arr);
  31. $this->registerJs('var depart_single=[' . $str . '];', $this::POS_BEGIN);
  32. ?>
  33. <style>
  34. .col_5 {
  35. width: 520px;
  36. }
  37. .th_center {
  38. text-align: center;
  39. }
  40. .my_label {
  41. width: 100px !important;
  42. }
  43. </style>
  44. <input type="hidden" id="id" value="<?= $model->id ?>"/>
  45. <input type="hidden" id="isDetail" value="<?= $model->id ?>"/>
  46. <div class="iframe_box portlet light bordered">
  47. <ul class="nav nav-tabs choose_op nav_title">
  48. <li role="presentation" data-toggle="tab" class="active" id=""
  49. onclick="tab(<?= $model->id ?>, 1)">
  50. <a data-toggle="tab" href="#order_info" onclick="">出车详情</a>
  51. </li>
  52. <li role="presentation" data-toggle="tab" class="" id=""
  53. onclick="tab(<?= $model->id ?>,2)">
  54. <a data-toggle="tab" href="#order_log" onclick="">操作日志</a>
  55. </li>
  56. </ul>
  57. <div class="iframe_box portlet light bordered">
  58. <div role="tabpanel" class="tab-pane active" id="order_info">
  59. <?php
  60. Pjax::begin(['id' => 'bus_order_detail', 'timeout' => false]);
  61. ?>
  62. <div style="display: inline-flex;border: 1px solid lightgray;width: 100%">
  63. <div style="padding-top: 20px;padding-left: 20px;display: inline-block;width: 25%;height: 158px;border-right: 1px solid #ddd;vertical-align: top">
  64. <div class="">
  65. <span id="top-order-id" style="color: gray;">出车单号:<?= $model->bus_number ?></span>
  66. <span id="ludan" class="label label-primary hide_f" style="margin-left: 10px;"></span>
  67. </div>
  68. <div style="margin-top: 25px;" id="top-order-status-main">
  69. <span id="top-order-status"
  70. style="font-size: 16px;"><?= BusOrder::bus_order_status_array[$model->run_status] ?></span>
  71. <span style="margin-left: 15px;margin-right: 15px;">
  72. <?= $model->run_status == 434 ? '<label class="separator"> </label>' . $model::bus_order_status_array[$model->send_status] : '' ?>
  73. <?= $model->run_status == 438 ? '<label class="separator"> </label>' . $model::bus_order_status_array[$model->finance_status] : '' ?></span>
  74. <span></span>
  75. </div>
  76. <div style="margin-top: 25px;">
  77. <span id="use_bus_org">用车单位:<?= $model->department == true ? $model->department->depart_name : '' ?></span>
  78. <span></span>
  79. </div>
  80. <div style="margin-top: 10px;">
  81. <span style="opacity: 0;">空空空空:</span>
  82. <span id=""></span>
  83. </div>
  84. </div>
  85. <div style="display: inline-block;width: 73%;vertical-align: top;">
  86. <!--中间五个环-->
  87. <div style="padding-top: 20px;">
  88. <div id="fuelux-wizard" class="row-fluid" data-target="#step-container">
  89. <ul class="wizard-steps">
  90. <li data-target="#step1" class="<?= $cancel ? 'active' : '' ?>">
  91. <span class="step">1</span>
  92. <span class="title">添加出车</span>
  93. <span class="title order_sub_date" id="create_date"></span>
  94. <span class="title order_sub_time" id="create_time"></span>
  95. </li>
  96. <li data-target="#step2"
  97. class="<?= ($model->send_status == 442 && $cancel) ? "active" : "" ?>">
  98. <span class="step">2</span>
  99. <span class="title">调度确认</span>
  100. <span class="title order_sub_date" id="pay_date"></span>
  101. <span class="title order_sub_time" id="pay_time"></span>
  102. </li>
  103. <li data-target="#step3"
  104. class="<?= (in_array($model->run_status, [434, 435, 436]) || !$cancel) ? "" : "active" ?>">
  105. <span class="step">3</span>
  106. <span class="title">出车准备</span>
  107. <span class="title order_sub_date" id="send_date"></span>
  108. <span class="title order_sub_time" id="send_time"></span>
  109. </li>
  110. <li data-target="#step4"
  111. class="<?= (in_array($model->run_status, [434, 435, 436, 437]) || !$cancel) ? "" : "active" ?>">
  112. <span class="step">4</span>
  113. <span class="title">出车</span>
  114. <span class="title order_sub_date" id="arr_date"></span>
  115. <span class="title order_sub_time" id="arr_time"></span>
  116. </li>
  117. <li data-target="#step5"
  118. class="<?= ($model->finance_status == 444 || !$cancel) ? "" : "active" ?>">
  119. <span class="step">5</span>
  120. <span class="title">出车完报账</span>
  121. <span class="title order_sub_date" id="finish_date"></span>
  122. <span class="title order_sub_time" id="finish_time"></span>
  123. </li>
  124. <li data-target="#step6"
  125. class="<?= ($model->finance_status == 446 && $cancel) ? "active" : "" ?>">
  126. <span class="step">6</span>
  127. <span class="title">报账审核</span>
  128. <span class="title order_sub_date" id="pay_date"></span>
  129. <span class="title order_sub_time" id="pay_time"></span>
  130. </li>
  131. <li data-target="#step7"
  132. class="<?= ($model->end_status == 449 && $cancel) ? "active" : "" ?>">
  133. <span class="step">7</span>
  134. <span class="title">收支结算</span>
  135. <span class="title order_sub_date" id="pay_date"></span>
  136. <span class="title order_sub_time" id="pay_time"></span>
  137. </li>
  138. </ul>
  139. </div>
  140. </div>
  141. <hr style="width: 90%"/>
  142. <div style="padding-left: 30px;">
  143. <?php
  144. if (!in_array($model->run_status, [437, 438, 439])) {
  145. ?>
  146. <button id="cancel" type="button" class="btn btn-secondary">
  147. <!--<span class="glyphicon glyphicon-remove-circle"></span> -->取消
  148. </button>
  149. <?php
  150. }
  151. ?>
  152. </div>
  153. </div>
  154. </div>
  155. <?php
  156. Pjax::end();
  157. ?>
  158. <div id="add-bus" class="panel panel-default" style="margin-top: 20px;">
  159. <div class="panel-heading">出车需求<span class="label label-sm label-status"></span></div>
  160. <div class="panel-body">
  161. <?php
  162. $form = zActiveForm::begin(['action' => '/motorcade/bus/save-bus', 'id' => 'run-form', 'options' => ['class' => 'form-horizontal']]);
  163. ?>
  164. <div class="form-body">
  165. <div class="" style="padding-left: 50px;padding-top: 10px;">
  166. <!--第一行-->
  167. <div class="form-group">
  168. <div class="form-inline">
  169. <div class="form-group" id="use_bus_org_id">
  170. <?= $form->field($model, 'use_bus_org_id', ['template' => '{label}<div class="col-sm-8" style="display: inline-flex">{input}' .
  171. '{hint}{error}</div>', 'options' => ['class' => 'col_5']])->dropDownList($data['bus_depart']['data'], ['class' => 'form-control go_select_screen ' . ($model->run_id != 0 ? 'select_screen_run_id run_id' : ''), 'style' => 'width: 172px;']) ?>
  172. </div>
  173. <!--出车时间-->
  174. <div class="form-group">
  175. <?= $form->field($model, 'run_date', ['template' => '{label}<div class="col-sm-8" style="display: inline-flex;width: auto;padding-right: 0 !important;"><div class="input-group date form_date">' .
  176. '{input}<span class="input-group-addon ' . ($model->run_id != 0 ? 'run_date_sync"' : '"') . '><span class="glyphicon glyphicon-calendar"></span></span>' .
  177. '</div>{hint}{error}</div>',
  178. 'options' => ['class' => 'col_5']])->textInput(['maxlength' => true, 'disabled' => true, 'class' => 'form-control ' . ($model->run_id != 0 ? 'run_id' : '')]) ?>
  179. </div>
  180. </div>
  181. </div>
  182. <!--第二行-->
  183. <div class="form-group">
  184. <div class="form-inline">
  185. <div class="form-group">
  186. <?= $form->field($model, 'itinerary_name', ['template' => '{label}<div class="col-sm-9 " style="display: inline-flex;">{input}' .
  187. '{hint}{error}</div>', 'options' => ['class' => 'col_5']])->textInput(['placeholder' => '输入线路名称', ['class' => 'form-control']]) ?>
  188. </div>
  189. <div class="form-group">
  190. <?= $form->field($model, 'bus_type_res_id', ['template' => '{label}<div class="col-sm-8" style="display: inline-flex">{input}' .
  191. '{hint}{error}</div>', 'options' => ['class' => 'col_5']])->dropDownList(ArrayHelper::map($data['bus_type']['data'], 'res_id', 'res_name'), ['class' => 'form-control', 'style' => 'width:172px;']) ?>
  192. </div>
  193. </div>
  194. </div>
  195. <!--第三行-->
  196. <div class="form-group">
  197. <div class="form-inline">
  198. <div class="form-group">
  199. <?= $form->field($model, 'saled_count', ['template' => '{label}<div class="col-sm-9 " style="display: inline-flex;"><div class="">{input}' .
  200. '</div>{hint}{error}</div>', 'options' => ['class' => 'col_5']])->textInput(['placeholder' => '输入乘客人数', ['class' => 'form-control']]) ?>
  201. </div>
  202. <div class="form-group">
  203. <?= $form->field($model, 'line_type', ['template' => '{label}<div class="col-sm-8" style="display: inline-flex">{input}' .
  204. '{hint}{error}</div>', 'options' => ['class' => 'col_5']])->dropDownList(['1' => '省际', '2' => '市内'], ['class' => 'form-control', 'style' => 'width:172px;']) ?>
  205. </div>
  206. </div>
  207. </div>
  208. <!--第四行-->
  209. <div class="form-group">
  210. <div class="form-inline">
  211. <div class="form-group">
  212. <?= $form->field($model, 'day_num', ['template' => '{label}<div class="col-sm-8" style="display: inline-flex">{input}' .
  213. '{hint}{error}</div>', 'options' => ['class' => 'col_5']])->dropDownList(\backend\modules\motorcade\models\BusOrder::getDayNum(), ['id' => 'stroke_select', 'class' => 'form-control', 'style' => 'width:172px;']) ?>
  214. </div>
  215. </div>
  216. </div>
  217. <!--第五行-->
  218. <div class="form-group">
  219. <div class="form-inline">
  220. <div class="col_5">
  221. <?php
  222. $dyModel = $model->itinerary;
  223. if ($dyModel == null || empty($dyModel)) {
  224. $dyModel[0] = new BusItinerary();
  225. }
  226. \wbraganca\dynamicform\DynamicFormWidget::begin([
  227. 'widgetContainer' => 'dynamicform_wrapper', // required: only alphanumeric characters plus "_" [A-Za-z0-9_]
  228. 'widgetBody' => '.stroke_tbody', // required: css class selector
  229. 'widgetItem' => '.line-item', // required: css class
  230. // 'limit' => 4, // the maximum times, an element can be added (default 999)
  231. 'min' => 1, // 0 or 1 (default 1)
  232. 'insertButton' => '.add-item', // css class
  233. 'deleteButton' => '.remove-item', // css class
  234. 'model' => $dyModel[0],
  235. 'formId' => 'run-form',
  236. 'formFields' => [
  237. 'station_name'
  238. ],
  239. ]); ?>
  240. <label id="" class="control-label required" aria-required="true"
  241. style="width: 12%">详细行程</label>
  242. <button type="button" class="btn btn-primary add-item"
  243. style="margin-left: 15px;"
  244. onclick="">
  245. <span class="glyphicon glyphicon-plus"></span> 添加
  246. </button>
  247. <div class="form-group" style="margin-left: 76px;margin-top: 16px;">
  248. <div class="form-inline" style="width:700px;">
  249. <table id="stroke_tbody" class="table table-bordered table-hover"
  250. style="text-align: center">
  251. <thead>
  252. <tr>
  253. <th class="th_center"> 站点 / 区域</th>
  254. <th class="th_center"> 上下客</th>
  255. <th class="th_center"> 出发 / 到达时间</th>
  256. <th class="th_center"> 操作</th>
  257. </tr>
  258. </thead>
  259. <tbody id="stroke_tbody" class="stroke_tbody">
  260. <?php
  261. foreach ((count($model->itinerary_list) > 0 ? $model->itinerary_list : $dyModel) as $key => $itinerary) {
  262. ?>
  263. <tr class="stroke_tr line-item">
  264. <td>
  265. <?= $form->field($itinerary, "[$key]id")->textInput()->hiddenInput()->label(false);
  266. echo Html::hiddenInput("tr_no", $key);
  267. ?>
  268. <div class="form-group" style="margin-left: 12px;">
  269. <div class="form-inline">
  270. <?= $form->field($itinerary, "[$key]station_name")->textInput(['placeholder' => '输入站点 / 区域名称', ['class' => 'form-control go_select_screen']])->label(false)->error(false); ?>
  271. </div>
  272. </div>
  273. </td>
  274. <td>
  275. <div class="form-group">
  276. <div class="form-inline">
  277. <?= $form->field($itinerary, "[$key]inout_type", ['template' => '<div class="col-sm-8" ><div class="form-group">{input}' .
  278. '</div>{hint}{error}</div>'])->dropDownList(['108' => '上', '109' => '上下', '110' => '下'], ['class' => 'form-control'])->error(false); ?>
  279. </div>
  280. </div>
  281. </td>
  282. <td>
  283. <div class="form-group">
  284. <div class="form-inline">
  285. <?= $form->field($itinerary, "[$key]day_seq_id", ['template' => '<div class="col-sm-8" ><div class="form-group">{input}' .
  286. '</div>{hint}{error}</div>'])->dropDownList(\backend\modules\motorcade\models\BusOrder::getDayNum(), ['class' => 'form-control'])->error(false) ?>
  287. <?= $form->field($itinerary, "[$key]start_time", ['template' => '<div id="time_id' . $key . '" style="margin-left: 40px;" class="timepicker_box">
  288. <span class="form-inline timepicker">
  289. <input type="text" class="form-control" value="' . $itinerary['start_time'] . '" name="BusItinerary[' . $key . '][start_time]" disabled>
  290. <span class="glyphicon glyphicon-time"></span>
  291. </span>
  292. <div class="timepicker_select" style="z-index: 10">
  293. <div class="select_hour_box"></div>
  294. <div class="select_minute_box"></div>
  295. </div>
  296. </div>'])->label(false)->error(false); ?>
  297. </div>
  298. </div>
  299. </td>
  300. <td style="vertical-align: middle !important;">
  301. <button type="button"
  302. class="btn btn-danger remove-item">删除
  303. </button>
  304. </td>
  305. </tr>
  306. <?php
  307. }
  308. ?>
  309. </tbody>
  310. </table>
  311. </div>
  312. </div>
  313. <?php \wbraganca\dynamicform\DynamicFormWidget::end(); ?>
  314. </div>
  315. </div>
  316. </div>
  317. <!--第六行-->
  318. <div class="form-group">
  319. <div class="form-inline">
  320. <div class="form-group">
  321. <?= $form->field($model, 'remark', ['template' => '{label}<div class="col-sm-9 " style="display: inline-flex;"><div class="">{input}' .
  322. '</div>{hint}{error}</div>', 'options' => ['class' => 'col_5']])->textInput(['placeholder' => '请输入用车备注', ['class' => 'form-control', 'style' => 'width:90px;']]) ?>
  323. </div>
  324. <div class="form-group">
  325. <?= $form->field($model, 'bus_cost_type', ['template' => '{label}<div class="col-sm-8" style="display: inline-flex;width:140px;">{input}' .
  326. '{hint}{error}</div>', 'options' => ['class' => 'col_5']])->dropDownList(['477' => '包车计价', '478' => '车座计价'], ['class' => 'form-control ' . ($model->run_id != 0 ? 'select_screen_run_id run_id' : ''), 'style' => 'width:110px;']) ?>
  327. <?= $form->field($model, 'bus_cost', ['template' => '{label}<div class="col-sm-9 " style="display: inline-flex;width:250px;"><div class="input-group form-inline input-group-with-addon" style="width: 120px;margin-left: 15px;">{input}' .
  328. '<div class="input-group-addon " style="width: auto">元</div></div>{hint}{error}</div>'])->textInput(['class' => 'form-control ' . ($model->run_id != 0 ? 'run_id' : ''), 'placeholder' => '金额', 'style' => ''])->label(false) ?>
  329. </div>
  330. </div>
  331. </div>
  332. <!--第七行-->
  333. <div class="form-group">
  334. <div class="form-inline">
  335. <div class="form-group">
  336. <?= $form->field($model, 'contacts', ['template' => '{label}<div class="col-sm-9" style="display: inline-flex;width:100px;"><div class="">{input}' .
  337. '</div>{hint}{error}</div>', 'options' => ['class' => 'col_5']])->textInput(['class' => 'form-control', 'placeholder' => '联系人', 'style' => 'width:100px;']) ?>
  338. <?= $form->field($model, 'tels', ['template' => '{label}<div class="col-sm-9 " style="display: inline-flex;width:100px;margin-left: 25px;"><div class="">{input}' .
  339. '</div>{hint}{error}</div>'])->textInput(['class' => 'form-control', 'placeholder' => '联系电话', 'style' => 'width:120px;margin-left:5px;'])->label(false) ?>
  340. </div>
  341. </div>
  342. </div>
  343. <!-- 第八行 -->
  344. <div id="single" class="form-group hidden">
  345. <div class="form-inline">
  346. <div class="form-group">
  347. <?= $form->field($model, 'single_contact', ['template' => '{label}<div class="col-sm-9" style="display: inline-flex;"><div class="">{input}' .
  348. '</div>{hint}{error}</div>', 'options' => ['class' => 'col_5']])->textInput(['class' => 'form-control', 'placeholder' => '收款人', 'style' => 'width:100px;']) ?>
  349. </div>
  350. </div>
  351. </div>
  352. <!-- 修改按钮 -->
  353. <div class="form-group">
  354. <div class="form-inline">
  355. <div class="form-group">
  356. <div class="col_5 field-busorder-contacts">
  357. <label class="control-label" for="busorder-contacts"> </label>
  358. </div>
  359. <div class="col-sm-9">
  360. <?php
  361. if ($model->finance_lock == 0 && $model->finance_status != 446) {
  362. echo Html::button('变更', ['class' => 'btn btn-default control', 'onclick' => 'runEditable(this)']);
  363. }
  364. ?>
  365. </div>
  366. </div>
  367. </div>
  368. </div>
  369. </div>
  370. <?php
  371. zActiveForm::end();
  372. ?>
  373. </div>
  374. </div>
  375. </div>
  376. <div id="dispatch-bus" class="panel panel-default" style="margin-top: 20px;">
  377. <div class="panel-heading">
  378. <div class="caption">
  379. 调度安排<span id="send_status"
  380. class="label label-info"><?= $model::bus_order_status_array[$model->send_status] ?></span>
  381. </div>
  382. </div>
  383. <div class="panel-body">
  384. <div class="" id="send_detail" style="padding-top: 5px;">
  385. <?php
  386. //显示状态,并显示调度的详情,如果没有就显示“等待安排调度”
  387. $busInfo = $model->bus;
  388. $driverInfo = $model->driver;
  389. if ($driverInfo || $busInfo) {
  390. if ($model->send_type == 1)
  391. echo '<span class="label label-sm label-outside">外部派车</span>';
  392. $busOrg = $busInfo->org;
  393. //历史数据原因,有可能没有品牌信息等
  394. if (!$busOrg)
  395. $busOrg = new \common\models\BaseSupplier();
  396. $busBrand = $busInfo->brand;
  397. if (!$busBrand)
  398. $busBrand = new \common\models\BaseResource();
  399. if (!$driverInfo)
  400. $driverInfo = new \backend\modules\motorcade\models\BaseDriver();
  401. ?>
  402. <div class="block-group"><label class="detail-title">车价:</label>
  403. <label class="detail-content"><?= $model->send_cost ?>元 </label>
  404. <label class="separator">|</label>
  405. <label class="detail-content"><?= $busOrg ? $busOrg->SUPPLIER_NAME : '' ?></label>
  406. </div>
  407. <div class="block-group">
  408. <label class="detail-title">车辆:</label>
  409. <label class="detail-content"><?= $busInfo->BUS_NO ?></label>
  410. <label class="separator">|</label>
  411. <label class="detail-content"> <?= $busBrand->RES_NAME ?> </label>
  412. <label class="separator">|</label>
  413. <label class="detail-content"> <?= $busInfo->SEAT_DESC ?> </label>
  414. </div>
  415. <div class="block-group">
  416. <label class="detail-title">司机:</label>
  417. <label class="detail-content"><?= $driverInfo->DRIVER_NAME ?> </label>
  418. <label class="separator">|</label>
  419. <label class="detail-content"><?= $driverInfo->PHONE_NO ?> </label>
  420. </div>
  421. <?php
  422. } else {
  423. $driverInfo = $driverInfo == null ? (new \backend\modules\motorcade\models\BaseDriver()) : $driverInfo;
  424. $busInfo = $busInfo == null ? (new \backend\modules\motorcade\models\BaseBus()) : $busInfo;
  425. echo '等待安排调度';
  426. }
  427. ?>
  428. </div>
  429. <div class="act-group row" id="send_action">
  430. <?php
  431. if (in_array($model->run_status, [434, 435, 436]) && in_array($model->send_status, [441, 442])) {
  432. ?>
  433. <button class="btn-right btn btn-default" id="resend" onclick="resend(<?= $model->id ?>)">
  434. 重新调度
  435. </button>
  436. <?php
  437. }
  438. ?>
  439. </div>
  440. </div>
  441. </div>
  442. <?php
  443. Pjax::begin(['id' => '_status-pjax', 'timeout' => false]);
  444. ?>
  445. <div id="apply-fee1"></div>
  446. <div id="apply-fee" class="panel panel-default" style="margin-top: 20px;">
  447. <div class="panel-heading">
  448. <div class="caption">
  449. 收车报账<span
  450. class="label label-info"><?= BusOrder::bus_order_status_array[$model->finance_status] ?></span>
  451. </div>
  452. <div class="tools">
  453. <a href="javascript:;" class="collapse" data-original-title="" title=""> </a>
  454. </div>
  455. </div>
  456. <div class="panel-body">
  457. <?php
  458. $form = zActiveForm::begin(['action' => '/motorcade/bus/save-finance', 'id' => 'finance-form', 'options' => ['class' => 'form-horizontal']]);
  459. ?>
  460. <div class="table-title">出车支出</div>
  461. <?php
  462. //内部派车和外部派车显示内容不同
  463. if ($model->send_type == 0) {
  464. $expense = $model->expense;
  465. $tmp = [];
  466. //因里程数需要拆分故处理数组
  467. if (isset($expense[0])) {
  468. if ($expense[0]['expense_subject_id'] == 462) {
  469. $temp = new RunBusExpenses();
  470. $temp->setAttributes($expense[0]->getAttributes());
  471. $tmp[0] = $temp;
  472. $tmp[0]['expense_subject_id'] = 526;
  473. for ($i = 0; $i < count($expense); $i++) {
  474. $tmp[$i + 1] = $expense[$i];
  475. }
  476. }
  477. }
  478. $dataProvider = new \yii\data\ArrayDataProvider([
  479. 'allModels' => isset($tmp) ? $tmp : $expense,
  480. ]);
  481. echo GridView::widget([
  482. 'dataProvider' => $dataProvider,
  483. 'summary' => '',
  484. 'emptyText' => '尚未报账,等待司机报账',
  485. 'resizableColumns' => false,
  486. 'responsive' => false,
  487. 'options' => ['class' => 'apply-table'],
  488. 'columns' => [
  489. [
  490. 'header' => '支出科目',
  491. 'attribute' => 'subject.TYPE_NAME',
  492. 'width' => '90px',
  493. 'hAlign' => 'center'
  494. ],
  495. [
  496. 'header' => '支出方式',
  497. 'attribute' => 'payType.TYPE_NAME',
  498. 'width' => '90px',
  499. 'hAlign' => 'center'
  500. ],
  501. [
  502. 'width' => '130px',
  503. 'hAlign' => 'center',
  504. 'header' => '金额',
  505. 'attribute' => 'expense_value',
  506. 'value' => function ($model) {
  507. $str = Html::activeHiddenInput($model, "[{$model->ID}]ID");
  508. if (in_array($model->expense_subject_id, [462, 463])) {
  509. $str .= '<div class="input-group">' . Html::activeTextInput($model, "[{$model->ID}]expense_value", ['readonly' => true, 'class' => 'unEditable input-sm form-control', 'id' => 'value' . $model->expense_subject_id, 'style' => 'border: 1px lightgray solid;']) . '<span class="input-group-addon" style="line-height: normal;padding: 0px 10px;">元</span></div>';
  510. } else if (in_array($model->expense_subject_id, [526])) {
  511. $model->end_value = intval($model->end_value);
  512. $model->start_value = intval($model->start_value);
  513. $str .= '<div class="input-group">' . Html::TextInput('miles', $model->end_value > 0 ? $model->end_value - $model->start_value : '', ['readonly' => true, 'class' => 'unEditable input-sm form-control', 'style' => 'border: 1px lightgray solid;']) . '<span class="input-group-addon" style="line-height: normal;padding: 0px 10px;">公里</span></div>';
  514. } else {
  515. $str .= '<div class="input-group">' . Html::activeTextInput($model, "[{$model->ID}]expense_value", ['readonly' => true, 'class' => 'editable input-sm form-control', 'style' => 'border: 1px lightgray solid;']) . '<span class="input-group-addon" style="line-height: normal;padding: 0px 10px;">元</span></div>';
  516. }
  517. return $str;
  518. },
  519. 'format' => 'raw',
  520. 'pageSummary' => true
  521. ],
  522. [
  523. 'header' => '明细',
  524. 'headerOptions' => ['class' => 'col-md-6'],
  525. 'contentOptions' => ['class' => 'form-inline'],
  526. 'value' => function ($model) use ($expense) {
  527. //油电费
  528. if ($model->expense_subject_id == 526) {
  529. return "<label class='col-wd-2 text-right label-margin' >开始</label>" . '<div class="input-group" style="display: inline-table;">' .
  530. Html::activeTextInput($model, "[{$expense[0]->ID}]start_value", ['readonly' => true, 'class' => 'editable input-sm', 'id' => 'mile_start', 'style' => 'border: 1px lightgray solid;width:90px']) . '<span class="input-group-addon" style="line-height: normal;padding:0px 10px">公里</span></div>' .
  531. "<label class='col-wd-2 text-right label-margin' >结束</label>" . '<div class="input-group" style="display:inline-table">' .
  532. Html::activeTextInput($model, "[{$expense[0]->ID}]end_value", ['readonly' => true, 'class' => 'editable input-sm', 'id' => 'mile_end', 'style' => 'border: 1px lightgray solid;width:90px']) . '<span class="input-group-addon" style="line-height: normal;padding:0px 10px">公里</span></div>';
  533. } elseif ($model->expense_subject_id == 463) {
  534. return "<label class='col-wd-2 text-right label-margin' >开始</label>" . '<div class="input-group" style="display: inline-table;">' .
  535. Html::activeTextInput($model, "[{$model->ID}]start_value", ['readonly' => true, 'class' => 'editable input-sm', 'id' => 'etc_start', 'style' => 'border: 1px lightgray solid;width:90px']) . '<span class="input-group-addon" style="line-height: normal;padding:0px 10px">元</span></div>' .
  536. "<label class='col-wd-2 text-right label-margin' >结束</label>" . '<div class="input-group" style="display: inline-table;">' .
  537. Html::activeTextInput($model, "[{$model->ID}]end_value", ['readonly' => true, 'class' => 'editable input-sm', 'id' => 'etc_end', 'style' => 'border: 1px lightgray solid;width:90px']) . '<span class="input-group-addon" style="line-height: normal;padding:0px 10px">元</span></div>';
  538. } else {
  539. return '';
  540. }
  541. },
  542. 'format' => 'raw',
  543. 'hAlign' => 'left',
  544. ],
  545. [
  546. 'header' => '报账人',
  547. 'attribute' => 'user.TRUE_NAME',
  548. 'width' => '100px',
  549. 'hAlign' => 'center'
  550. ],
  551. [
  552. 'width' => '100px',
  553. 'hAlign' => 'center',
  554. 'header' => '报账时间',
  555. // 'attribute' => 'create_time',
  556. 'attribute' => function ($model) {
  557. return substr($model['create_time'], 0, 10);
  558. }
  559. ]
  560. ]
  561. ]);
  562. } elseif ($busInfo->ORG_ID) {
  563. $outsideSupplier = BaseSupplier::find()->joinWith('settleType')->where(['cancel_flag' => 0, BaseSupplier::tableName() . '.ID' => $busInfo->ORG_ID])->one();
  564. if ($outsideSupplier !== null) {
  565. $tmpData = ['subject' => '外部用车价', 'settle_type' => $outsideSupplier->settleType->TYPE_NAME,
  566. 'company' => $outsideSupplier->COMPANY_NAME,
  567. 'price' => $model->send_cost, 'count' => 1, 'total' => $model->send_cost];
  568. $tmpDataProvider = new \yii\data\ArrayDataProvider([
  569. 'allModels' => [$tmpData],
  570. ]);
  571. echo GridView::widget([
  572. 'summary' => '',
  573. 'resizableColumns' => false,
  574. 'responsive' => false,
  575. 'options' => ['class' => 'apply-table'],
  576. 'dataProvider' => $tmpDataProvider,
  577. 'columns' => [
  578. [
  579. 'width' => '13%',
  580. 'attribute' => 'subject',
  581. 'header' => '支出科目',
  582. ],
  583. [
  584. 'width' => '13%',
  585. 'attribute' => 'settle_type',
  586. 'header' => '结算方式',
  587. ],
  588. [
  589. 'attribute' => 'company',
  590. 'header' => '结算单位',
  591. ],
  592. [
  593. 'width' => '13%',
  594. 'attribute' => 'price',
  595. 'header' => '车价',
  596. 'value' => function ($item) use ($model) {
  597. return '<span class="income-span">' . $item['price'] . '</span>'
  598. . Html::activeTextInput($model, 'send_cost', ['class' => 'hidden form-control income-input'])
  599. . Html::activeHiddenInput($model, 'id');
  600. },
  601. 'format' => 'raw'
  602. ],
  603. [
  604. 'width' => '13%',
  605. 'attribute' => 'count',
  606. 'header' => '数量',
  607. ],
  608. [
  609. 'width' => '13%',
  610. 'attribute' => 'total',
  611. 'header' => '总计',
  612. ],
  613. ]
  614. ]);
  615. }
  616. }
  617. ?>
  618. <br/>
  619. <div class="table-title">出车收入</div>
  620. <table class="kv-grid-table table table-bordered table-striped kv-table-wrap">
  621. <thead>
  622. <tr>
  623. <th style="width: 13%">收入科目</th>
  624. <th style="width: 13%">结算方式</th>
  625. <th style="">结算单位</th>
  626. <th style="width: 13%">车价</th>
  627. <th style="width: 13%">数量</th>
  628. <th style="width: 13%">总计</th>
  629. </tr>
  630. </thead>
  631. <tbody>
  632. <?php
  633. $depart = $model->department;
  634. ?>
  635. <tr>
  636. <td>
  637. 车价<?= $form->field($model, 'id', ['options' => ['class' => '']])->hiddenInput()->label(false)->error(false) ?></td>
  638. <td><?= $depart ? $depart->settleType->TYPE_NAME : '' ?></td>
  639. <td><?= $depart ? $depart->depart_name : '' ?></td>
  640. <td>
  641. <span class="income-span"><?= $model->busCostType ? ($model->bus_cost_type == 477 ? $model->bus_cost . '元' : $model->bus_cost . '元/次') : '' ?></span>
  642. <div class="inline-flex income-input hidden">
  643. <?= $form->field($model, 'bus_cost_type', ['options' => ['class' => 'inline-input']])->dropDownList(['477' => '包车计价', '478' => '车座计价'], ['class' => 'form-control', 'style' => 'width:110px;'])->label(false)->error(false) ?>
  644. <?= $form->field($model, 'bus_cost', ['options' => ['class' => 'inline-input']])->textInput(['style' => 'width:110px;', 'placeHolder' => '金额'])->label(false)->error(false) ?>
  645. </div>
  646. </td>
  647. <td>
  648. <span class="income-span"><?= $model->busCostType ? ($model->bus_cost_type == 477 ? 1 : $model->saled_count . '人') : '' ?></span>
  649. <div class="inline-flex income-input hidden"><?= $form->field($model, 'saled_count', ['options' => ['class' => 'inline-input']])->textInput(['style' => 'width:110px;'])->label(false)->error(false) ?>
  650. <span style="padding: 7px">人</span></div>
  651. </td>
  652. <td><?= $model->busCostType ? $model->bus_cost_type == 477 ? $model->bus_cost : ($model->bus_cost * $model->saled_count) : '' ?></td>
  653. </tr>
  654. </tbody>
  655. </table>
  656. <?php
  657. zActiveForm::end();
  658. ?>
  659. <div class="act-group row">
  660. <?php
  661. //变更按钮 未报账 待审核
  662. if ($model->finance_lock == 0 && in_array($model->finance_status, [BusOrder::STATUS_FINANCE_WAITING, BusOrder::STATUS_FINANCE_SURE, BusOrder::STATUS_FINANCE_REJECT])) {
  663. ?>
  664. <button id="finance_change" class="btn btn-default btn-right" style="margin-right: 40px;"
  665. onclick="financeEditable(this)">
  666. 变更
  667. </button>
  668. <?php if ($model->finance_status == BusOrder::STATUS_FINANCE_WAITING) { ?>
  669. <button class="btn-right btn btn-default"
  670. onclick="Reject(<?= $model->id ?>, 'finance_status', '#_status-pjax')"
  671. data-pjax>驳回
  672. </button>
  673. <button class="btn-right btn btn-default"
  674. onclick="Sure(<?= $model->id ?>, 'finance_status', '#_status-pjax')"
  675. data-pjax>审核通过
  676. </button>
  677. <?php
  678. }
  679. }
  680. if ($model->finance_status == 447) { //被驳回,显示驳回原因
  681. $statusLog = BusOrderStatusLog::find()->where(['TYPE' => BusOrderStatusLog::$_type_array['FINANCE_STATUS']])->orderBy('CREATE_TIME DESC')->one();
  682. if ($statusLog) {
  683. $str = $statusLog->user->TRUE_NAME . ' 于 ' . $statusLog->CREATE_TIME . ' 驳回,原因:' . $statusLog->MSG;
  684. echo Html::label($str, null, ['class' => 'right label-footer']);
  685. }
  686. }
  687. // if ($model->finance_status == 445) {
  688. // ?>
  689. <!---->
  690. <!-- --><?php
  691. // }
  692. ?>
  693. </div>
  694. </div>
  695. </div>
  696. <div id="settlement1"></div>
  697. <div id="settlement" class="panel panel-default" style="margin-top: 20px;">
  698. <div class="panel-heading">
  699. <div class="caption">
  700. 收支结算<span class="label label-sm label-status"></span>
  701. </div>
  702. </div>
  703. <div class="panel-body">
  704. <div class="table-title">收入结算</div>
  705. <table class="kv-grid-table table table-bordered table-striped kv-table-wrap">
  706. <thead>
  707. <tr>
  708. <th>用车单位</th>
  709. <th>结算方式</th>
  710. <th>结算周期</th>
  711. <th>车价</th>
  712. <th>结算状态</th>
  713. <th>结算时间</th>
  714. <th>操作人</th>
  715. </tr>
  716. </thead>
  717. <tbody>
  718. <tr>
  719. <td><?= $depart ? $depart->depart_name : '' ?></td>
  720. <td><?= $depart ? $depart->settleType->TYPE_NAME : '' ?></td>
  721. <td><?= $depart ? $depart->settleCycle->TYPE_NAME : '' ?></td>
  722. <td><?= $model->busCostType ? (strpos($model->busCostType->TYPE_NAME, '人数') === false ? $model->bus_cost : ($model->bus_cost * $model->saled_count)) : '' ?>
  723. </td>
  724. <td><?= $model->getEndStatusLabel() ?></td>
  725. <?php
  726. if ($model->end_status == 448) {
  727. echo '<td>-</td><td>-</td>';
  728. } else {
  729. $endStatus = BusOrderStatusLog::find()->where(['BUS_NUMBER' => $model->bus_number, 'TYPE' => BusOrderStatusLog::$_type_array['END_STATUS']])->orderBy('CREATE_TIME DESC')->one();
  730. if ($endStatus != null) {
  731. echo "<td>{$endStatus->CREATE_TIME}</td><td>{$endStatus->user->TRUE_NAME}</td>";
  732. } else {
  733. echo '<td>-</td><td>-</td>';
  734. }
  735. }
  736. ?>
  737. </tr>
  738. </tbody>
  739. </table>
  740. <br/>
  741. <div class="table-title">支出结算</div>
  742. <table class="kv-grid-table table table-bordered table-striped kv-table-wrap">
  743. <?php
  744. //支出结算取决于内部用车还是外部用车
  745. if ($model->send_type == 0) { //内部
  746. $fees = RunBusExpenses::find()->where(['bus_number' => $model->bus_number, 'cancel_flag' => 0])->all();
  747. //把费用科目对应的dict_type作为键值,方便读取;
  748. $tmp = [];
  749. foreach ($fees as $fee) {
  750. $tmp[$fee->expense_subject_id] = $fee;
  751. }
  752. $fees = $tmp;
  753. ?>
  754. <thead>
  755. <tr>
  756. <th>司机</th>
  757. <th>车辆</th>
  758. <th>公里数</th>
  759. <th>油费</th>
  760. <th>路桥费</th>
  761. <th>司贴</th>
  762. <th>停车费</th>
  763. <th>餐饮费</th>
  764. <th>住宿费</th>
  765. </tr>
  766. </thead>
  767. <tbody>
  768. <tr>
  769. <td><?= $driverInfo->DRIVER_NAME ?></td>
  770. <td><?= $busInfo->BUS_NO ?></td>
  771. <td><?php
  772. if (isset($fees[$model::$bus_order_fee_array['FEE_OIL']])) {
  773. $tmp = $fees[$model::$bus_order_fee_array['FEE_OIL']];
  774. echo $tmp->end_value - $tmp->start_value;
  775. }
  776. ?></td>
  777. <td><?= isset($fees[$model::$bus_order_fee_array['FEE_OIL']]) ? $fees[$model::$bus_order_fee_array['FEE_OIL']]->expense_value : '-' ?></td>
  778. <td><?= isset($fees[$model::$bus_order_fee_array['FEE_BRIDGE']]) ? $fees[$model::$bus_order_fee_array['FEE_BRIDGE']]->expense_value : '-' ?></td>
  779. <td><?= isset($fees[$model::$bus_order_fee_array['FEE_DRIVER']]) ? $fees[$model::$bus_order_fee_array['FEE_DRIVER']]->expense_value : '-' ?></td>
  780. <td><?= isset($fees[$model::$bus_order_fee_array['FEE_PARK']]) ? $fees[$model::$bus_order_fee_array['FEE_PARK']]->expense_value : '-' ?></td>
  781. <td><?= isset($fees[$model::$bus_order_fee_array['FEE_FOOD']]) ? $fees[$model::$bus_order_fee_array['FEE_FOOD']]->expense_value : '-' ?></td>
  782. <td><?= isset($fees[$model::$bus_order_fee_array['FEE_HOTEL']]) ? $fees[$model::$bus_order_fee_array['FEE_HOTEL']]->expense_value : '-' ?></td>
  783. </tr>
  784. </tbody>
  785. <?php
  786. } else if ($model->send_type == 1) {
  787. $outsideSupplier = BaseSupplier::find()->where(['cancel_flag' => 0, 'ID' => $busInfo->ORG_ID])->one();
  788. if ($outsideSupplier == null) {
  789. $outsideSupplier = new BaseSupplier();
  790. }
  791. ?>
  792. <thead>
  793. <tr>
  794. <th>外部用车</th>
  795. <th>结算方式</th>
  796. <th>结算周期</th>
  797. <th>车价</th>
  798. </tr>
  799. </thead>
  800. <tbody>
  801. <tr>
  802. <td><?= $outsideSupplier->SUPPLIER_NAME ?></td>
  803. <td><?= $outsideSupplier->settleType ? $outsideSupplier->settleType->TYPE_NAME : '' ?></td>
  804. <td><?= $outsideSupplier->settleType ? $outsideSupplier->settleCycle->TYPE_NAME : '' ?></td>
  805. <td><?= $model->send_cost ?></td>
  806. </tr>
  807. </tbody>
  808. <?php
  809. }
  810. ?>
  811. </table>
  812. <div class="act-group row">
  813. <!--
  814. <?php
  815. //报账审核通过 且 未结算 显示确定驳回按钮
  816. if ($model->finance_status == 446 && $model->end_status == 448) {
  817. ?>
  818. <button class="right btn btn-default" onclick="Reject(<?= $model->id ?>, 'end_status')"
  819. data-pjax>驳回
  820. </button>
  821. <button class="right btn btn-default" onclick="Sure(<?= $model->id ?>, 'end_status')" data-pjax>
  822. 通过
  823. </button>
  824. <?php
  825. } else if ($model->end_status == 482) { //被驳回,显示驳回原因
  826. $statusLog = BusOrderStatusLog::find()->where(['TYPE' => BusOrderStatusLog::$_type_array['END_STATUS']])->orderBy('CREATE_TIME DESC')->one();
  827. if ($statusLog) {
  828. $str = $statusLog->user->TRUE_NAME . ' 于 ' . $statusLog->CREATE_TIME . ' 驳回,原因:' . $statusLog->MSG;
  829. echo Html::label($str, null, ['class' => 'right label-footer']);
  830. }
  831. }
  832. ?>
  833. -->
  834. </div>
  835. </div>
  836. </div>
  837. </div>
  838. </div>
  839. <!--操作日志-->
  840. <div role="tabpanel" class="tab-pane" id="order_log">
  841. <div class="table-responsive" style="width: 1000px">
  842. <table class="table table-striped table-bordered">
  843. <thead>
  844. <tr>
  845. <th>操作人</th>
  846. <th>操作时间</th>
  847. <th>操作内容</th>
  848. </tr>
  849. </thead>
  850. <tbody>
  851. <?php
  852. if (empty($data['bus_log'])) {
  853. echo '<tr><td colspan="3" style="text-align: center">无操作日志</td></tr>';
  854. } else {
  855. foreach ($data['bus_log'] as $val) {
  856. echo '<tr>';
  857. echo "<td>{$val['true_name']}</td>";
  858. echo "<td>{$val['created_at']}</td>";
  859. echo "<td>{$val['msg']}</td>";
  860. echo '</tr>';
  861. }
  862. }
  863. ?>
  864. </tbody>
  865. </table>
  866. </div>
  867. </div>
  868. </div>
  869. <?php
  870. Pjax::end();
  871. ?>