php codesniffer

This commit is contained in:
Florian Henry 2014-02-23 17:01:51 +01:00
parent 720746b1b2
commit d242f4930d
2 changed files with 1501 additions and 1825 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,107 +20,99 @@
*/ */
/** /**
* \file htdocs/societe/price.php * \file htdocs/societe/price.php
* \ingroup product * \ingroup product
* \brief Page to show product prices by customer * \brief Page to show product prices by customer
*/ */
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) { if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice ( $db ); $prodcustprice = new Productcustomerprice($db);
} }
$langs->load("products"); $langs->load("products");
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
// Security check // Security check
$socid = GETPOST('socid','int'); $socid = GETPOST('socid', 'int');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id)
$socid = $user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
/**
/***************************************************** * ***************************************************
* Price by customer * Price by customer
*****************************************************/ * ****************************************************
if ($action == 'add_customer_price_confirm' && ! $_POST["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) */
{ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$update_child_soc=GETPOST('updatechildprice'); $update_child_soc = GETPOST('updatechildprice');
//add price by customer // add price by customer
$prodcustprice->fk_soc=$socid; $prodcustprice->fk_soc = $socid;
$prodcustprice->fk_product=GETPOST('prodid','int'); $prodcustprice->fk_product = GETPOST('prodid', 'int');
$prodcustprice->price=price2num(GETPOST("price"),'MU'); $prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min=price2num(GETPOST("price_min"),'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type=GETPOST("price_base_type",'alpha'); $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx=str_replace('*','',GETPOST("tva_tx")); $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly=(preg_match('/\*/',GETPOST("tva_tx")) ? 1 : 0); $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$result = $prodcustprice->create($user,0,$update_child_soc); $result = $prodcustprice->create($user, 0, $update_child_soc);
if ($result < 0) if ($result < 0) {
{ setEventMessage($prodcustprice->error, 'errors');
setEventMessage($prodcustprice->error,'errors');
} else { } else {
setEventMessage($langs->trans('Save'),'mesgs'); setEventMessage($langs->trans('Save'), 'mesgs');
} }
$action=''; $action = '';
} }
if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
{ // Delete price by customer
//Delete price by customer $prodcustprice->id = GETPOST('lineid');
$prodcustprice->id=GETPOST('lineid');
$result = $prodcustprice->delete($user); $result = $prodcustprice->delete($user);
if ($result < 0) if ($result < 0) {
{ setEventMessage($prodcustprice->error, 'mesgs');
setEventMessage($prodcustprice->error,'mesgs'); } else {
}else { setEventMessage($langs->trans('Delete'), 'errors');
setEventMessage($langs->trans('Delete'),'errors');
} }
$action=''; $action = '';
} }
if ($action == 'update_customer_price_confirm' && ! $_POST["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
{
$prodcustprice->fetch(GETPOST('lineid','int')); $prodcustprice->fetch(GETPOST('lineid', 'int'));
$update_child_soc=GETPOST('updatechildprice'); $update_child_soc = GETPOST('updatechildprice');
//update price by customer // update price by customer
$prodcustprice->price=price2num(GETPOST("price"),'MU'); $prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min=price2num(GETPOST("price_min"),'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type=GETPOST("price_base_type",'alpha'); $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx=str_replace('*','',GETPOST("tva_tx")); $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly=(preg_match('/\*/',GETPOST("tva_tx")) ? 1 : 0); $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$result = $prodcustprice->update($user,0,$update_child_soc); $result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) if ($result < 0) {
{ setEventMessage($prodcustprice->error, 'errors');
setEventMessage($prodcustprice->error,'errors'); } else {
}else { setEventMessage($langs->trans('Save'), 'mesgs');
setEventMessage($langs->trans('Save'),'mesgs');
} }
$action=''; $action = '';
} }
/* /*
* View * View
*/ */
@ -129,94 +121,90 @@ $form = new Form($db);
$soc = new Societe($db); $soc = new Societe($db);
$result = $soc->fetch($socid); $result = $soc->fetch($socid);
llxHeader("",$langs->trans("ThirdParty").'-'. $langs->trans ( 'PriceByCustomer' )); llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer'));
if (! empty($conf->notification->enabled)) $langs->load("mails"); if (! empty($conf->notification->enabled))
$langs->load("mails");
$head = societe_prepare_head($soc); $head = societe_prepare_head($soc);
dol_fiche_head($head, 'price', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), 0, 'company');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td><td colspan="3">'; print '<tr><td width="25%">' . $langs->trans("ThirdPartyName") . '</td><td colspan="3">';
print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); print $form->showrefnav($soc, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
print '</td></tr>'; print '</td></tr>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{ {
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$soc->prefix_comm.'</td></tr>'; print '<tr><td>' . $langs->trans('Prefix') . '</td><td colspan="3">' . $soc->prefix_comm . '</td></tr>';
} }
if ($soc->client) if ($soc->client) {
{
print '<tr><td>'; print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode') . '</td><td colspan="3">';
print $soc->code_client; print $soc->code_client;
if ($soc->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; if ($soc->check_codeclient() != 0)
print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>';
print '</td></tr>'; print '</td></tr>';
} }
if ($soc->fournisseur) if ($soc->fournisseur) {
{
print '<tr><td>'; print '<tr><td>';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode') . '</td><td colspan="3">';
print $soc->code_fournisseur; print $soc->code_fournisseur;
if ($soc->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; if ($soc->check_codefournisseur() != 0)
print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>';
print '</td></tr>'; print '</td></tr>';
} }
if (! empty($conf->barcode->enabled)) if (! empty($conf->barcode->enabled)) {
{ print '<tr><td>' . $langs->trans('Gencod') . '</td><td colspan="3">' . $soc->barcode . '</td></tr>';
print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="3">'.$soc->barcode.'</td></tr>';
} }
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">"; print "<tr><td valign=\"top\">" . $langs->trans('Address') . "</td><td colspan=\"3\">";
dol_print_address($soc->address, 'gmap', 'thirdparty', $soc->id); dol_print_address($soc->address, 'gmap', 'thirdparty', $soc->id);
print "</td></tr>"; print "</td></tr>";
// Zip / Town // Zip / Town
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$soc->zip."</td>"; print '<tr><td width="25%">' . $langs->trans('Zip') . '</td><td width="25%">' . $soc->zip . "</td>";
print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->town."</td></tr>"; print '<td width="25%">' . $langs->trans('Town') . '</td><td width="25%">' . $soc->town . "</td></tr>";
// Country // Country
if ($soc->country) { if ($soc->country) {
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; print '<tr><td>' . $langs->trans('Country') . '</td><td colspan="3">';
$img=picto_from_langcode($soc->country_code); $img = picto_from_langcode($soc->country_code);
print ($img?$img.' ':''); print($img ? $img . ' ' : '');
print $soc->country; print $soc->country;
print '</td></tr>'; print '</td></tr>';
} }
// EMail // EMail
print '<tr><td>'.$langs->trans('EMail').'</td><td colspan="3">'; print '<tr><td>' . $langs->trans('EMail') . '</td><td colspan="3">';
print dol_print_email($soc->email,0,$soc->id,'AC_EMAIL'); print dol_print_email($soc->email, 0, $soc->id, 'AC_EMAIL');
print '</td></tr>'; print '</td></tr>';
// Web // Web
print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3">'; print '<tr><td>' . $langs->trans('Web') . '</td><td colspan="3">';
print dol_print_url($soc->url); print dol_print_url($soc->url);
print '</td></tr>'; print '</td></tr>';
// Phone / Fax // Phone / Fax
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->country_code,0,$soc->id,'AC_TEL').'</td>'; print '<tr><td>' . $langs->trans('Phone') . '</td><td>' . dol_print_phone($soc->tel, $soc->country_code, 0, $soc->id, 'AC_TEL') . '</td>';
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->country_code,0,$soc->id,'AC_FAX').'</td></tr>'; print '<td>' . $langs->trans('Fax') . '</td><td>' . dol_print_phone($soc->fax, $soc->country_code, 0, $soc->id, 'AC_FAX') . '</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
$prodcustprice = new Productcustomerprice ( $db ); $prodcustprice = new Productcustomerprice($db);
$sortfield = GETPOST ( "sortfield", 'alpha' ); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST ( "sortorder", 'alpha' ); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST ( "page", 'int' ); $page = GETPOST("page", 'int');
if ($page == - 1) { if ($page == - 1) {
$page = 0; $page = 0;
} }
@ -233,8 +221,8 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
't.fk_soc' => $soc->id 't.fk_soc' => $soc->id
); );
$search_soc = GETPOST ( 'search_soc' ); $search_soc = GETPOST('search_soc');
if (! empty ( $search_soc )) { if (! empty($search_soc)) {
$filter ['soc.nom'] = $search_soc; $filter ['soc.nom'] = $search_soc;
} }
@ -242,7 +230,7 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
// Create mode // Create mode
print_fiche_titre ( $langs->trans ( 'PriceByCustomer' ) ); print_fiche_titre($langs->trans('PriceByCustomer'));
print '<form action="' . $_SERVER ["PHP_SELF"] . '?socid=' . $soc->id . '" method="POST">'; print '<form action="' . $_SERVER ["PHP_SELF"] . '?socid=' . $soc->id . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
@ -250,52 +238,52 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print '<input type="hidden" name="socid" value="' . $soc->id . '">'; print '<input type="hidden" name="socid" value="' . $soc->id . '">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans ( 'Product' ) . '</td>'; print '<td>' . $langs->trans('Product') . '</td>';
print '<td>'; print '<td>';
print $form->select_produits('','prodid','',0); print $form->select_produits('', 'prodid', '', 0);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// VAT // VAT
print '<tr><td>' . $langs->trans ( "VATRate" ) . '</td><td>'; print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva ( "tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr ); print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr);
print '</td></tr>'; print '</td></tr>';
// Price base // Price base
print '<tr><td width="15%">'; print '<tr><td width="15%">';
print $langs->trans ( 'PriceBase' ); print $langs->trans('PriceBase');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $form->select_PriceBaseType ( $object->price_base_type, "price_base_type" ); print $form->select_PriceBaseType($object->price_base_type, "price_base_type");
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Price // Price
print '<tr><td width="20%">'; print '<tr><td width="20%">';
$text = $langs->trans ( 'SellingPrice' ); $text = $langs->trans('SellingPrice');
print $form->textwithpicto ( $text, $langs->trans ( "PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT ), 1, 1 ); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
print '</td><td>'; print '</td><td>';
if ($object->price_base_type == 'TTC') { if ($object->price_base_type == 'TTC') {
print '<input name="price" size="10" value="' . price ( $object->price_ttc ) . '">'; print '<input name="price" size="10" value="' . price($object->price_ttc) . '">';
} else { } else {
print '<input name="price" size="10" value="' . price ( $object->price ) . '">'; print '<input name="price" size="10" value="' . price($object->price) . '">';
} }
print '</td></tr>'; print '</td></tr>';
// Price minimum // Price minimum
print '<tr><td>'; print '<tr><td>';
$text = $langs->trans ( 'MinPrice' ); $text = $langs->trans('MinPrice');
print $form->textwithpicto ( $text, $langs->trans ( "PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT ), 1, 1 ); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
if ($object->price_base_type == 'TTC') { if ($object->price_base_type == 'TTC') {
print '<td><input name="price_min" size="10" value="' . price ( $object->price_min_ttc ) . '">'; print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">';
} else { } else {
print '<td><input name="price_min" size="10" value="' . price ( $object->price_min ) . '">'; print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
} }
print '</td></tr>'; print '</td></tr>';
// Update all child soc // Update all child soc
print '<tr><td width="15%">'; print '<tr><td width="15%">';
print $langs->trans ( 'ForceUpdateChildPriceSoc' ); print $langs->trans('ForceUpdateChildPriceSoc');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print '<input type="checkbox" name="updatechildprice" value="1"/>'; print '<input type="checkbox" name="updatechildprice" value="1"/>';
@ -304,19 +292,19 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print '</table>'; print '</table>';
print '<center><br><input type="submit" class="button" value="' . $langs->trans ( "Save" ) . '">&nbsp;'; print '<center><br><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans ( "Cancel" ) . '"></center>'; print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></center>';
print '<br></form>'; print '<br></form>';
} elseif ($action == 'edit_customer_price') { } elseif ($action == 'edit_customer_price') {
// Edit mode // Edit mode
print_fiche_titre ( $langs->trans ( 'PriceByCustomer' ) ); print_fiche_titre($langs->trans('PriceByCustomer'));
$result = $prodcustprice->fetch ( GETPOST ( 'lineid', 'int' ) ); $result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessage ( $prodcustprice->error, 'errors' ); setEventMessage($prodcustprice->error, 'errors');
} }
print '<form action="' . $_SERVER ["PHP_SELF"] . '?socid=' . $soc->id . '" method="POST">'; print '<form action="' . $_SERVER ["PHP_SELF"] . '?socid=' . $soc->id . '" method="POST">';
@ -325,52 +313,52 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">'; print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans ( 'Product' ) . '</td>'; print '<td>' . $langs->trans('Product') . '</td>';
$staticprod = new Product ( $db ); $staticprod = new Product($db);
$staticprod->fetch ( $prodcustprice->fk_product ); $staticprod->fetch($prodcustprice->fk_product);
print "<td>" . $staticprod->getNomUrl ( 1 ) . "</td>"; print "<td>" . $staticprod->getNomUrl(1) . "</td>";
print '</tr>'; print '</tr>';
// VAT // VAT
print '<tr><td>' . $langs->trans ( "VATRate" ) . '</td><td>'; print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva ( "tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly ); print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly);
print '</td></tr>'; print '</td></tr>';
// Price base // Price base
print '<tr><td width="15%">'; print '<tr><td width="15%">';
print $langs->trans ( 'PriceBase' ); print $langs->trans('PriceBase');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $form->select_PriceBaseType ( $prodcustprice->price_base_type, "price_base_type" ); print $form->select_PriceBaseType($prodcustprice->price_base_type, "price_base_type");
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Price // Price
print '<tr><td width="20%">'; print '<tr><td width="20%">';
$text = $langs->trans ( 'SellingPrice' ); $text = $langs->trans('SellingPrice');
print $form->textwithpicto ( $text, $langs->trans ( "PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT ), 1, 1 ); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
print '</td><td>'; print '</td><td>';
if ($prodcustprice->price_base_type == 'TTC') { if ($prodcustprice->price_base_type == 'TTC') {
print '<input name="price" size="10" value="' . price ( $prodcustprice->price_ttc ) . '">'; print '<input name="price" size="10" value="' . price($prodcustprice->price_ttc) . '">';
} else { } else {
print '<input name="price" size="10" value="' . price ( $prodcustprice->price ) . '">'; print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">';
} }
print '</td></tr>'; print '</td></tr>';
// Price minimum // Price minimum
print '<tr><td>'; print '<tr><td>';
$text = $langs->trans ( 'MinPrice' ); $text = $langs->trans('MinPrice');
print $form->textwithpicto ( $text, $langs->trans ( "PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT ), 1, 1 ); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
if ($prodcustprice->price_base_type == 'TTC') { if ($prodcustprice->price_base_type == 'TTC') {
print '<td><input name="price_min" size="10" value="' . price ( $prodcustprice->price_min_ttc ) . '">'; print '<td><input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">';
} else { } else {
print '<td><input name="price_min" size="10" value="' . price ( $prodcustprice->price_min ) . '">'; print '<td><input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
} }
print '</td></tr>'; print '</td></tr>';
// Update all child soc // Update all child soc
print '<tr><td width="15%">'; print '<tr><td width="15%">';
print $langs->trans ( 'ForceUpdateChildPriceSoc' ); print $langs->trans('ForceUpdateChildPriceSoc');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print '<input type="checkbox" name="updatechildprice" value="1">'; print '<input type="checkbox" name="updatechildprice" value="1">';
@ -379,112 +367,104 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print '</table>'; print '</table>';
print '<center><br><input type="submit" class="button" value="' . $langs->trans ( "Save" ) . '">&nbsp;'; print '<center><br><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans ( "Cancel" ) . '"></center>'; print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></center>';
print '<br></form>'; print '<br></form>';
} elseif ($action=='showlog_customer_price') { } elseif ($action == 'showlog_customer_price') {
$filter = array ( $filter = array (
't.fk_product' => GETPOST('prodid','int'), 't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid
't.fk_soc'=> $socid );
);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = 0; $nbtotalofrecords = 0;
if (empty ( $conf->global->MAIN_DISABLE_FULL_SCANLIST )) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all_log ( $sortorder, $sortfield, $conf->liste_limit, $offset, $filter ); $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
} }
$result = $prodcustprice->fetch_all_log ( $sortorder, $sortfield, $conf->liste_limit, $offset, $filter ); $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) { if ($result < 0) {
setEventMessage ( $prodcustprice->error, 'errors' ); setEventMessage($prodcustprice->error, 'errors');
} }
$option = '&socid=' . GETPOST('socid','int') . '&prodid=' . GETPOST('prodid','int'); $option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int');
print_barre_liste ( $langs->trans ( 'PriceByCustomerLog' ), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count ( $prodcustprice->lines ), $nbtotalofrecords ); print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
if (count ( $prodcustprice->lines ) > 0) { if (count($prodcustprice->lines) > 0) {
print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">'; print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans ( "Product" ) . '</td>'; print '<td>' . $langs->trans("Product") . '</td>';
print '<td>' . $langs->trans ( "AppliedPricesFrom" ) . '</td>'; print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
print '<td align="center">' . $langs->trans ( "PriceBase" ) . '</td>'; print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
print '<td align="right">' . $langs->trans ( "VAT" ) . '</td>'; print '<td align="right">' . $langs->trans("VAT") . '</td>';
print '<td align="right">' . $langs->trans ( "HT" ) . '</td>'; print '<td align="right">' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans ( "TTC" ) . '</td>'; print '<td align="right">' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans ( "MinPrice" ) . ' ' . $langs->trans ( "HT" ) . '</td>'; print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans ( "MinPrice" ) . ' ' . $langs->trans ( "TTC" ) . '</td>'; print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans ( "ChangedBy" ) . '</td>'; print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
$var = True; $var = True;
foreach ( $prodcustprice->lines as $line ) { foreach ( $prodcustprice->lines as $line ) {
print "<tr $bc[$var]>";
$staticprod = new Product ( $db );
$staticprod->fetch ( $line->fk_product );
print "<td>" . $staticprod->getNomUrl ( 1 ) . "</td>"; print "<tr $bc[$var]>";
print "<td>" . dol_print_date ( $line->datec, "dayhour" ) . "</td>"; $staticprod = new Product($db);
$staticprod->fetch($line->fk_product);
print '<td align="center">' . $langs->trans ( $line->price_base_type ) . "</td>";
print '<td align="right">' . vatrate ( $line->tva_tx, true, $line->recuperableonly ) . "</td>"; print "<td>" . $staticprod->getNomUrl(1) . "</td>";
print '<td align="right">' . price ( $line->price ) . "</td>"; print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="right">' . price ( $line->price_ttc ) . "</td>";
print '<td align="right">' . price ( $line->price_min ) . '</td>'; print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . price ( $line->price_min_ttc ) . '</td>'; print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
// User // User
$userstatic=new User($db); $userstatic = new User($db);
$userstatic->fetch($line->fk_user); $userstatic->fetch($line->fk_user);
print '<td align="right">'; print '<td align="right">';
print $userstatic->getLoginUrl(1); print $userstatic->getLoginUrl(1);
print '</td>'; print '</td>';
}
print "</table>";
} else {
} print $langs->trans('None');
print "</table>";
} else {
print $langs->trans ( 'None' );
} }
print "\n" . '<div class="tabsAction">' . "\n"; print "\n" . '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?socid=' . $soc->id . '">' . $langs->trans ( "Ok" ) . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?socid=' . $soc->id . '">' . $langs->trans("Ok") . '</a></div>';
print "\n</div><br>\n"; print "\n</div><br>\n";
} else { } else {
// View mode // View mode
// Count total nb of records // Count total nb of records
$nbtotalofrecords = 0; $nbtotalofrecords = 0;
if (empty ( $conf->global->MAIN_DISABLE_FULL_SCANLIST )) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all ( '', '', 0, 0, $filter ); $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
} }
$result = $prodcustprice->fetch_all ( $sortorder, $sortfield, $conf->liste_limit, $offset, $filter ); $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) { if ($result < 0) {
setEventMessage ( $prodcustprice->error, 'errors' ); setEventMessage($prodcustprice->error, 'errors');
} }
$option = '&search_soc=' . $search_soc . '&id=' . $object->id; $option = '&search_soc=' . $search_soc . '&id=' . $object->id;
print_barre_liste ( $langs->trans ( 'PriceByCustomer' ), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count ( $prodcustprice->lines ), $nbtotalofrecords ); print_barre_liste($langs->trans('PriceByCustomer'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
if (count ( $prodcustprice->lines ) > 0) { if (count($prodcustprice->lines) > 0) {
print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">'; print '<input type="hidden" name="id" value="' . $object->id . '">';
@ -492,15 +472,15 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans ( "Product" ) . '</td>'; print '<td>' . $langs->trans("Product") . '</td>';
print '<td>' . $langs->trans ( "AppliedPricesFrom" ) . '</td>'; print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
print '<td align="center">' . $langs->trans ( "PriceBase" ) . '</td>'; print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
print '<td align="right">' . $langs->trans ( "VAT" ) . '</td>'; print '<td align="right">' . $langs->trans("VAT") . '</td>';
print '<td align="right">' . $langs->trans ( "HT" ) . '</td>'; print '<td align="right">' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans ( "TTC" ) . '</td>'; print '<td align="right">' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans ( "MinPrice" ) . ' ' . $langs->trans ( "HT" ) . '</td>'; print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans ( "MinPrice" ) . ' ' . $langs->trans ( "TTC" ) . '</td>'; print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans ( "ChangedBy" ) . '</td>'; print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
@ -509,7 +489,7 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print '<td colspan="8">&nbsp;</td>'; print '<td colspan="8">&nbsp;</td>';
// Print the search button // Print the search button
print '<td class="liste_titre" align="right">'; print '<td class="liste_titre" align="right">';
print '<input class="liste_titre" name="button_search" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '" title="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '">'; print '<input class="liste_titre" name="button_search" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -518,40 +498,39 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
foreach ( $prodcustprice->lines as $line ) { foreach ( $prodcustprice->lines as $line ) {
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
$staticprod = new Product ( $db );
$staticprod->fetch ( $line->fk_product );
print "<td>" . $staticprod->getNomUrl ( 1 ) . "</td>"; $staticprod = new Product($db);
print "<td>" . dol_print_date ( $line->datec, "dayhour" ) . "</td>"; $staticprod->fetch($line->fk_product);
print '<td align="center">' . $langs->trans ( $line->price_base_type ) . "</td>"; print "<td>" . $staticprod->getNomUrl(1) . "</td>";
print '<td align="right">' . vatrate ( $line->tva_tx, true, $line->recuperableonly ) . "</td>"; print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="right">' . price ( $line->price ) . "</td>";
print '<td align="right">' . price ( $line->price_ttc ) . "</td>"; print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . price ( $line->price_min ) . '</td>'; print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price ( $line->price_min_ttc ) . '</td>'; print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
// User // User
$userstatic=new User($db); $userstatic = new User($db);
$userstatic->fetch($line->fk_user); $userstatic->fetch($line->fk_user);
print '<td align="right">'; print '<td align="right">';
print $userstatic->getLoginUrl(1); print $userstatic->getLoginUrl(1);
print '</td>'; print '</td>';
// Todo Edit or delete button // Todo Edit or delete button
// Action // Action
if ($user->rights->produit->creer || $user->rights->service->creer) { if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<td align="right">'; print '<td align="right">';
print '<a href="' . $_SERVER ["PHP_SELF"] . '?action=delete_customer_price&amp;socid=' . $soc->id . '&amp;lineid=' . $line->id . '">'; print '<a href="' . $_SERVER ["PHP_SELF"] . '?action=delete_customer_price&amp;socid=' . $soc->id . '&amp;lineid=' . $line->id . '">';
print img_delete (); print img_delete();
print '</a>'; print '</a>';
print '<a href="' . $_SERVER ["PHP_SELF"] . '?action=edit_customer_price&amp;socid=' . $soc->id . '&amp;lineid=' . $line->id . '">'; print '<a href="' . $_SERVER ["PHP_SELF"] . '?action=edit_customer_price&amp;socid=' . $soc->id . '&amp;lineid=' . $line->id . '">';
print img_edit (); print img_edit();
print '</a>'; print '</a>';
print '<a href="' . $_SERVER ["PHP_SELF"] . '?action=showlog_customer_price&amp;socid=' . $soc->id . '&amp;prodid=' . $line->fk_product . '">'; print '<a href="' . $_SERVER ["PHP_SELF"] . '?action=showlog_customer_price&amp;socid=' . $soc->id . '&amp;prodid=' . $line->fk_product . '">';
print img_info (); print img_info();
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} }
@ -562,7 +541,7 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print "</form>"; print "</form>";
} else { } else {
print $langs->trans ( 'None' ); print $langs->trans('None');
} }
/* ************************************************************************** */ /* ************************************************************************** */
@ -574,13 +553,12 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print "\n" . '<div class="tabsAction">' . "\n"; print "\n" . '<div class="tabsAction">' . "\n";
if ($user->rights->produit->creer || $user->rights->service->creer) { if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?action=add_customer_price&amp;socid=' . $soc->id . '">' . $langs->trans ( "AddCustomerPrice" ) . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?action=add_customer_price&amp;socid=' . $soc->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>';
} }
print "\n</div><br>\n"; print "\n</div><br>\n";
} }
} }
llxFooter(); llxFooter();
$db->close(); $db->close();