From 9ec792975396b708dd1e90fd535bcae94df26a9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Jun 2017 10:57:15 +0200 Subject: [PATCH] Look and feel v6 --- htdocs/margin/agentMargins.php | 25 +++- htdocs/margin/checkMargins.php | 237 +++++++++++++++--------------- htdocs/margin/customerMargins.php | 1 + htdocs/margin/productMargins.php | 1 + htdocs/theme/eldy/style.css.php | 5 +- htdocs/theme/md/style.css.php | 5 +- 6 files changed, 143 insertions(+), 131 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index e00eb4ae18b..6c3a246ad0d 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -34,14 +34,6 @@ $langs->load("bills"); $langs->load("products"); $langs->load("margins"); -// Security check - -if ($user->rights->margins->read->all) { - $agentid = GETPOST('agentid', 'int'); -} else { - $agentid = $user->id; -} - $mesg = ''; // Load variable for pagination @@ -69,6 +61,23 @@ if (!empty($_POST['startdatemonth'])) if (!empty($_POST['enddatemonth'])) $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']); +// Security check +if ($user->rights->margins->read->all) { + $agentid = GETPOST('agentid', 'int'); +} else { + $agentid = $user->id; +} +$result=restrictedArea($user,'margins'); + + +/* + * Actions + */ + +// None + + + /* * View */ diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index c576b3ce4a6..ab6394eb74c 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -34,72 +34,35 @@ $langs->load("bills"); $langs->load("products"); $langs->load("margins"); -// Security check - -if ($user->rights->margins->creer) { - $agentid = $user->id; -} else { - accessforbidden(); -} - -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortorder) - $sortorder = "DESC"; -if (! $sortfield) { - $sortfield = 'f.facnumber'; -} -$page = GETPOST("page", 'int'); -if ($page == - 1) { - $page = 0; -} -$offset = $conf->liste_limit * $page; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - -// Both test are required to be compatible with all browsers -if (GETPOST("button_search_x") || GETPOST("button_search")) { - $action = 'search'; -} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) { - $action = 'update'; -} - -if ($action == 'update') { - $datapost = $_POST; - - foreach ( $datapost as $key => $value ) { - if (strpos($key, 'buyingprice_') !== false) { - $tmp_array = explode('_', $key); - if (count($tmp_array) > 0) { - $invoicedet_id = $tmp_array[1]; - if (! empty($invoicedet_id)) { - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet'; - $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\''; - $sql .= ' WHERE rowid=' . $invoicedet_id; - $result = $db->query($sql); - if (!$result) { - setEventMessages($db->lasterror, null, 'errors'); - } - } - } - } - } -} +if (! $sortorder) $sortorder = "DESC"; +if (! $sortfield) $sortfield = 'f.facnumber'; $startdate = $enddate = ''; $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int')); $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear', 'int')); -if (! empty($startdate)) { - $options .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); -} -if (! empty($enddate)) { - $options .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); -} - $search_ref = GETPOST('search_ref','alpha'); +// Security check +$result=restrictedArea($user,'margins'); + +// Both test are required to be compatible with all browsers +if (GETPOST("button_search_x") || GETPOST("button_search")) { + $action = 'search'; +} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) { + $action = 'update'; +} + /* * Actions @@ -117,6 +80,28 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + if ($action == 'update') { + $datapost = $_POST; + + foreach ( $datapost as $key => $value ) { + if (strpos($key, 'buyingprice_') !== false) { + $tmp_array = explode('_', $key); + if (count($tmp_array) > 0) { + $invoicedet_id = $tmp_array[1]; + if (! empty($invoicedet_id)) { + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet'; + $sql .= ' SET buy_price_ht=\'' . price2num($value) . '\''; + $sql .= ' WHERE rowid=' . $invoicedet_id; + $result = $db->query($sql); + if (!$result) { + setEventMessages($db->lasterror, null, 'errors'); + } + } + } + } + } + } + // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { @@ -155,6 +140,17 @@ llxHeader('', $title); // print_fiche_titre($text); +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if (! empty($startdate)) { + $param .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int'); +} +if (! empty($enddate)) { + $param .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int'); +} +if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Show tabs $head = marges_prepare_head($user); $picto = 'margin'; @@ -202,7 +198,7 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - + dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); if ($result) { @@ -212,31 +208,30 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } } -$sql .= $db->plimit($conf->liste_limit + 1, $offset); +$sql .= $db->plimit($limit+1, $offset); -dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - + print '
'; - print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - + print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); + if ($conf->global->MARGIN_TYPE == "1") $labelcostprice=$langs->trans('BuyingPrice'); else // value is 'costprice' or 'pmp' $labelcostprice=$langs->trans('CostPrice'); - + $moreforfilter=''; - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields //if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); $selectedfields=''; - + print '
'; print ''."\n"; - + print ''; print ''; print ''; @@ -249,66 +244,66 @@ if ($result) { print $searchpitco; print ''; print "\n"; - + print ''; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.facnumber", "", $options, '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $options, 'width=20%', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $options, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $param, 'width=20%', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - - if ($num > 0) { - while ($objp = $db->fetch_object($result)) - { - $var = ! $var; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print "\n"; - - $i ++; + + $i=0; + while ($i < min($num, $limit)) + { + $objp = $db->fetch_object($result); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "\n"; + + $i ++; } + print "
'; - $result_inner = $invoicestatic->fetch($objp->invoiceid); - if ($result_inner < 0) { - setEventMessages($invoicestatic->error, null, 'errors'); - } else { - print $invoicestatic->getNomUrl(1); - } - print ''; - if (! empty($objp->fk_product)) { - $result_inner = $productstatic->fetch($objp->fk_product); - if ($result_inner < 0) { - setEventMessages($productstatic->error, null, 'errors'); - } else { - print $productstatic->getNomUrl(1); - } - } else { - print $objp->label; - print ' '; - print $objp->description; - } - print ''; - print price($objp->subprice); - print ''; - print ''; - print ''; - print $objp->qty; - print ''; - print price($objp->total_ht); - print '
'; + $result_inner = $invoicestatic->fetch($objp->invoiceid); + if ($result_inner < 0) { + setEventMessages($invoicestatic->error, null, 'errors'); + } else { + print $invoicestatic->getNomUrl(1); } + print ''; + if (! empty($objp->fk_product)) { + $result_inner = $productstatic->fetch($objp->fk_product); + if ($result_inner < 0) { + setEventMessages($productstatic->error, null, 'errors'); + } else { + print $productstatic->getNomUrl(1); + } + } else { + print $objp->label; + print ' '; + print $objp->description; + } + print ''; + print price($objp->subprice); + print ''; + print ''; + print ''; + print $objp->qty; + print ''; + print price($objp->total_ht); + print '
"; - + print "
"; } else { dol_print_error($db); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index ed76cde223c..643fdcb4704 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -37,6 +37,7 @@ $langs->load("margins"); $socid = GETPOST('socid','int'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); +$result = restrictedArea($user,'margins'); $mesg = ''; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 43a9ef0f22e..77f7e23c84f 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -43,6 +43,7 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); +$result=restrictedArea($user,'margins'); $mesg = ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index c3bfa8b05cb..3f05f66c82b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -4043,12 +4043,15 @@ a span.select2-chosen .css-searchselectcombo ul.select2-results { max-height: none; } -.select2-container-multi.select2-container-disabled .select2-choices { +.select2-container.select2-container-disabled .select2-choice, .select2-container-multi.select2-container-disabled .select2-choices { background-color: #FFFFFF; background-image: none; border: none; cursor: default; } +.select2-container-disabled .select2-choice .select2-arrow b { + opacity: 0.5; +} .select2-container-multi .select2-choices .select2-search-choice { margin-bottom: 3px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e96fa032538..802eb46f6af 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4128,12 +4128,15 @@ a span.select2-chosen .css-searchselectcombo ul.select2-results { max-height: none; } -.select2-container-multi.select2-container-disabled .select2-choices { +.select2-container.select2-container-disabled .select2-choice, .select2-container-multi.select2-container-disabled .select2-choices { background-color: #FFFFFF; background-image: none; border: none; cursor: default; } +.select2-container-disabled .select2-choice .select2-arrow b { + opacity: 0.5; +} .select2-container-multi .select2-choices .select2-search-choice { margin-bottom: 3px; }