Look and feel v6

This commit is contained in:
Laurent Destailleur 2017-06-21 10:57:15 +02:00
parent ce8a024d44
commit 9ec7929753
6 changed files with 143 additions and 131 deletions

View File

@ -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
*/

View File

@ -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 '<br>';
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 '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre liste_titre_search">';
print '<td><input type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
print '<td></td>';
@ -249,66 +244,66 @@ if ($result) {
print $searchpitco;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
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 "</tr>\n";
if ($num > 0) {
while ($objp = $db->fetch_object($result))
{
$var = ! $var;
print '<tr class="oddeven">';
print '<td>';
$result_inner = $invoicestatic->fetch($objp->invoiceid);
if ($result_inner < 0) {
setEventMessages($invoicestatic->error, null, 'errors');
} else {
print $invoicestatic->getNomUrl(1);
}
print '</td>';
print '<td>';
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 '&nbsp;';
print $objp->description;
}
print '</td>';
print '<td align="right">';
print price($objp->subprice);
print '</td>';
print '<td align="right">';
print '<input type="text" name="buyingprice_' . $objp->invoicedetid . '" id="buyingprice_' . $objp->invoicedetid . '" size="6" value="' . price($objp->buy_price_ht) . '" class="flat">';
print '</td>';
print '<td align="right">';
print $objp->qty;
print '</td>';
print '<td align="right">';
print price($objp->total_ht);
print '</td>';
print '<td></td>';
print "</tr>\n";
$i ++;
$i=0;
while ($i < min($num, $limit))
{
$objp = $db->fetch_object($result);
print '<tr class="oddeven">';
print '<td>';
$result_inner = $invoicestatic->fetch($objp->invoiceid);
if ($result_inner < 0) {
setEventMessages($invoicestatic->error, null, 'errors');
} else {
print $invoicestatic->getNomUrl(1);
}
print '</td>';
print '<td>';
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 '&nbsp;';
print $objp->description;
}
print '</td>';
print '<td align="right">';
print price($objp->subprice);
print '</td>';
print '<td align="right">';
print '<input type="text" name="buyingprice_' . $objp->invoicedetid . '" id="buyingprice_' . $objp->invoicedetid . '" size="6" value="' . price($objp->buy_price_ht) . '" class="right flat">';
print '</td>';
print '<td align="right">';
print $objp->qty;
print '</td>';
print '<td align="right">';
print price($objp->total_ht);
print '</td>';
print '<td></td>';
print "</tr>\n";
$i ++;
}
print "</table>";
print "</div>";
} else {
dol_print_error($db);

View File

@ -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 = '';

View File

@ -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 = '';

View File

@ -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;
}

View File

@ -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;
}