From: Alexander Smirnov Date: Thu, 21 Dec 2023 13:36:13 +0000 (+0300) Subject: add write-offs/index and comments during moving from pure php to yii X-Git-Tag: 1.1~197^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=5f098f8934b7f73a975c1c1b0ddd1afb9c807d78;p=erp24_rep%2Fyii-erp24%2F.git add write-offs/index and comments during moving from pure php to yii --- diff --git a/erp24/actions/writeOffs/CommentsAction.php b/erp24/actions/writeOffs/CommentsAction.php new file mode 100644 index 00000000..d869860a --- /dev/null +++ b/erp24/actions/writeOffs/CommentsAction.php @@ -0,0 +1,12 @@ +controller->render('comments'); + } +} \ No newline at end of file diff --git a/erp24/actions/writeOffs/IndexAction.php b/erp24/actions/writeOffs/IndexAction.php new file mode 100644 index 00000000..be77be7d --- /dev/null +++ b/erp24/actions/writeOffs/IndexAction.php @@ -0,0 +1,12 @@ +controller->render('index'); + } +} \ No newline at end of file diff --git a/erp24/controllers/WriteOffsController.php b/erp24/controllers/WriteOffsController.php new file mode 100644 index 00000000..eb25081b --- /dev/null +++ b/erp24/controllers/WriteOffsController.php @@ -0,0 +1,16 @@ + \yii_app\actions\writeOffs\IndexAction::class, + 'comments' => \yii_app\actions\writeOffs\CommentsAction::class, + ]; + } +} \ No newline at end of file diff --git a/erp24/views/write-offs/comments.php b/erp24/views/write-offs/comments.php new file mode 100644 index 00000000..dcc870d7 --- /dev/null +++ b/erp24/views/write-offs/comments.php @@ -0,0 +1,270 @@ +
'; + + +// группировка для автозаказа +$commentsArray=[ + 1=>"Перетарка", + 2=>"Брак с поставки", + 3=>"Ошибка в работе с цветком", +]; + +// причины списаний для администраторов +$commentsArray=[ + 1=>"Перетарка", + 2=>"Брак с поставки", + 3=>"Плохой цветок с поставки", + 4=>"Флорист неверно обработал цветок", + 5=>"Собранный букет был не из матрицы", + 6=>"Администратор вовремя не поставил задачу по обработке" +]; + + + + + + +if(!empty($_POST["save"])) { + + foreach($_POST["comments"] as $product_id => $comArr ) { + $product_id=htmlentities($product_id); + + $db::sql("DELETE FROM write_offs_comments WHERE write_offs_id=? AND product_id=? ",[$write_offs_id,$product_id]); + + foreach($comArr as $com_id => $quantity) { + + $com_id=(int)$com_id; + + if(!empty($com_id) and !empty($quantity)) { + $sql="INSERT IGNORE INTO write_offs_comments SET write_offs_id=?, + product_id=?, comment_id=? , quantity=? ON DUPLICATE KEY UPDATE comment_id=?, quantity=?, date_update=NOW() "; + $db::sql($sql,[$write_offs_id,$product_id,$com_id, $quantity, $com_id,$quantity]); + } + } + + } + + +// суммируем количество по всем причинам + $quantityCom=array(); + $data=$db::getRows("SELECT product_id, sum(quantity) as quantity FROM write_offs_comments WHERE write_offs_id=? group by product_id",[$write_offs_id]); + foreach($data as $row) $quantityCom[$row["product_id"]]=$row["quantity"]; + + + $data=$db::getRows("SELECT product_id,quantity FROM write_offs_products WHERE write_offs_id=?",[$write_offs_id]); + foreach($data as $row) { + $itemsProductsArr[$row["product_id"]]=$row["quantity"]; + } + + foreach($itemsProductsArr ?? [] as $pid =>$q){ + if($quantityCom[$pid]>$itemsProductsArr[$pid]) { + + error_mess("Суммарное значение ".$products[$pid]." больше количества списания! "); + } + } + + + mess("Сохранили"); +} + + +$comments=array(); +$data=$db::getRows("SELECT * FROM write_offs_comments WHERE write_offs_id=?",[$write_offs_id]); +foreach($data as $row) $comments[$row["product_id"]][$row["comment_id"]]=$row["quantity"]; + + + +$data=$db::getRows("SELECT *,DATE_FORMAT(date, '%d.%m.%Y %H:%i') as date2 FROM write_offs WHERE id=?",[$write_offs_id]); +foreach($data as $row) { + $items=json_decode($row["items"],true,512,JSON_UNESCAPED_UNICODE); + + echo'

Списание '.$row["number"].' '.$stores[$row["store_id"]].' '.$row["summ"].' руб.

+дата '.$row["date2"].' тип '.$row["type"].' +'.$row["based_on"].' Комментарий '.$row["comment"]; + + echo'
+ + +'; + foreach($commentsArray as $nameC) echo''; + + /**/ + + echo''; + rsort($items); + + $j=0; + + foreach($items as $k => $mass) { + + if($j==14) { echo''; + foreach($commentsArray as $nameC) echo''; + echo''; + $j=0; + } + + + $j++; + echo''; + + + foreach($commentsArray as $comId => $nameC) echo''; + + + + echo''; + } + + + + echo'
Наименованиекол-во'.$nameC.'
Наименованиекол-во'.$nameC.'
'.$products[$mass["product_id"]].''.$mass["quantity"].'
+'; + + +} +echo'
'; + + + +echo''; + + + + +$_CONFIG["jscss"]=' + + + +'; + + + +include_once dirname(__DIR__, 2) . '/templates/bottom_light.php'; + + + + diff --git a/erp24/views/write-offs/index.php b/erp24/views/write-offs/index.php new file mode 100644 index 00000000..d50877c9 --- /dev/null +++ b/erp24/views/write-offs/index.php @@ -0,0 +1,125 @@ +='$date1'"; $get .="&date1=$date1"; } +if(!empty($_REQUEST["date2"])) {$date2=htmlentities($_REQUEST["date2"]); $where .=" AND date<='$date2'"; $get .="&date2=$date2";} +if(!empty($_REQUEST["store_id"])) {$store_id=htmlentities($_REQUEST["store_id"]); $where .=" AND store_id='$store_id'"; $get .="&store_id=$store_id";} + + +if(!empty($_REQUEST["type"]) and $_REQUEST["type"]!="-все-") {$type=htmlentities($_REQUEST["type"]); $where .=" AND type='$type'"; $get .="&type=$type";} + +$stores=$db::mapping("SELECT id,name FROM products_1c WHERE tip='city_store' AND view='1' "); +$products=$db::mapping("SELECT id,name FROM products_1c WHERE tip='products' "); + +$stiresDostup=""; +$where .=" AND store_id in ('"; +$k=0; +foreach( $stores as $guid => $store) { + if(in_array($guid,$_SESSION["store_arr_guid_dostup"])) { + if($k!=0) $where .="','"; + $where .=$guid; + $stiresDostup .="".$store.""; + + $k++; + } +} +$where .="')"; + + +echo"
Доступные магазины $stiresDostup
"; + +$limit = 100; +$offset = !empty($_GET['p'])?(($_GET['p']-1)*$limit):0; +$offset=(int)$offset; +//получаем количество записей +$resultNum = $db::getRow("SELECT COUNT(*) as postNum FROM write_offs WHERE 1 $where",); +$rowCount = $resultNum['postNum']; +//инициализируем класс pagination +$pagConfig = array('baseURL'=>'/'.$modul.'/?'.$get.'', 'totalRows'=>$rowCount, 'perPage'=>$limit ); +$pagination = new Pagination($pagConfig); //получаем записи + + + +$select=array("-все-","Брак","Списание по инвентаризации","Брак с поставки","Списание на затраты (подарки)"); + +echo'

Списания

'; + + +echo'
+ + + +
'; + +echo'
+ + + + + + +'; +$summ_retail=0; +$data=$db::getRows("SELECT *,DATE_FORMAT(date, '%d.%m.%Y %H:%i') as date2 FROM write_offs WHERE 1 $where order by date DESC LIMIT $offset,$limit"); +foreach($data as $row) { + + + $items=json_decode($row["items"],true,512,JSON_UNESCAPED_UNICODE); + + echo' + +'; + + echo''; + +} +echo'
сумма закупочныесумма в розничныхместомагазин датанаименование
'.$row["summ"].''.$row["summ_retail"].''.$row["write_downs"].''; + + + $summ_retail +=$row["summ_retail"]; + $summ +=$row["summ"]; + + if(empty($store_id)) echo''.$stores[$row["store_id"]].' '; + + echo' + +комментарии +'.$row["date2"].' '.$row["type"].''.$row["number"].' '.$row["based_on"].' '.$row["comment"].' +'; + echo'
'; + +echo'Итого в розничных '.$summ_retail.' Итого в закупке '.$summ.''; + +echo'
'; + +if(!empty($data)) echo $pagination->createLinks(); + +include_once dirname(__DIR__, 2) . '/templates/bottom_light.php';