From: pavlikov_maxim Date: Thu, 18 Apr 2024 12:12:43 +0000 (+0300) Subject: фикс модуля write-offs X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=89f13637c3300e691b6c106de39d381a4709a42f;p=yii-erp24%2F.git фикс модуля write-offs --- diff --git a/erp24/views/write-offs/index.php b/erp24/views/write-offs/index.php index d50877c..bf56f5d 100644 --- a/erp24/views/write-offs/index.php +++ b/erp24/views/write-offs/index.php @@ -7,70 +7,87 @@ include_once(dirname(__DIR__, 2) . "/inc/design_new.php"); error_reporting(E_ALL ^ E_NOTICE); -$modul="write-offs"; - -$where=""; $get=""; -if(!empty($_REQUEST["date1"])) {$date1=htmlentities($_REQUEST["date1"]); $where .=" AND date>='$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";} +$modul = "write-offs"; + +$where = ""; +$get = ""; +if (!empty($_REQUEST["date1"])) { + $date1 = htmlentities($_REQUEST["date1"]); + $where .= " AND date>='$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";} +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' "); +$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) { + if (in_array($guid, $_SESSION["store_arr_guid_dostup"])) { + if ($k != 0) $where .= "','"; + $where .= $guid; + $stiresDostup .= "".$store.""; + $stiresDostup .= " mt-2 me-2 btn-sm\">" . $store . ""; $k++; } } -$where .="')"; +$where .= "')"; -echo"
Доступные магазины $stiresDostup
"; +echo "
Доступные магазины $stiresDostup
"; $limit = 100; -$offset = !empty($_GET['p'])?(($_GET['p']-1)*$limit):0; -$offset=(int)$offset; +$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']; +$resultNum = $db::run("SELECT COUNT(*) as postNum FROM write_offs WHERE 1 $where"); +$resultNum = $resultNum ? $resultNum->fetchAll() : false; +$rowCount = isset($resultNum['postNum']) ? $resultNum['postNum'] : 0; //инициализируем класс pagination -$pagConfig = array('baseURL'=>'/'.$modul.'/?'.$get.'', 'totalRows'=>$rowCount, 'perPage'=>$limit ); -$pagination = new Pagination($pagConfig); //получаем записи - +$pagConfig = array('baseURL' => '/' . $modul . '/?' . $get . '', 'totalRows' => $rowCount, 'perPage' => $limit); +$pagination = new Pagination($pagConfig); //получаем записи -$select=array("-все-","Брак","Списание по инвентаризации","Брак с поставки","Списание на затраты (подарки)"); +$select = array("-все-", "Брак", "Списание по инвентаризации", "Брак с поставки", "Списание на затраты (подарки)"); -echo'

Списания

'; +echo '

Списания

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