28 require 
'../../main.inc.php';
 
   30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
 
   31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
 
   32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
 
   33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
 
   34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
 
   35 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
 
   36 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
 
   38   require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
 
   42 $langs->loadLangs(array(
"companies", 
"compta", 
"accountancy", 
"products"));
 
   48 if (!$user->hasRight(
'accounting', 
'bind', 
'write')) {
 
   53 $action = 
GETPOST(
'action', 
'aZ09');
 
   54 $massaction = 
GETPOST(
'massaction', 
'alpha');
 
   55 $codeventil_buy = 
GETPOST(
'codeventil_buy', 
'array');
 
   56 $codeventil_sell = 
GETPOST(
'codeventil_sell', 
'array');
 
   57 $chk_prod = 
GETPOST(
'chk_prod', 
'array');
 
   58 $default_account = 
GETPOST(
'default_account', 
'int');
 
   59 $confirm = 
GETPOST(
'confirm', 
'alpha');
 
   60 $account_number_buy = 
GETPOST(
'account_number_buy');
 
   61 $account_number_sell = 
GETPOST(
'account_number_sell');
 
   62 $changeaccount = 
GETPOST(
'changeaccount', 
'array');
 
   63 $changeaccount_buy = 
GETPOST(
'changeaccount_buy', 
'array');
 
   64 $changeaccount_sell = 
GETPOST(
'changeaccount_sell', 
'array');
 
   65 $searchCategoryProductOperator = (
GETPOST(
'search_category_product_operator', 
'int') ? 
GETPOST(
'search_category_product_operator', 
'int') : 0);
 
   66 $searchCategoryProductList = 
GETPOST(
'search_category_product_list', 
'array');
 
   67 $search_ref = 
GETPOST(
'search_ref', 
'alpha');
 
   68 $search_label = 
GETPOST(
'search_label', 
'alpha');
 
   69 $search_desc = 
GETPOST(
'search_desc', 
'alpha');
 
   70 $search_vat = 
GETPOST(
'search_vat', 
'alpha');
 
   71 $search_current_account = 
GETPOST(
'search_current_account', 
'alpha');
 
   72 $search_current_account_valid = 
GETPOST(
'search_current_account_valid', 
'alpha');
 
   73 if ($search_current_account_valid == 
'') {
 
   74   $search_current_account_valid = 
'withoutvalidaccount';
 
   76 $search_onsell = 
GETPOST(
'search_onsell', 
'alpha');
 
   77 $search_onpurchase = 
GETPOST(
'search_onpurchase', 
'alpha');
 
   79 $accounting_product_mode = 
GETPOST(
'accounting_product_mode', 
'alpha');
 
   80 $btn_changetype = 
GETPOST(
'changetype', 
'alpha');
 
   81 $optioncss = 
GETPOST(
'optioncss', 
'alpha');
 
   83 if (empty($accounting_product_mode)) {
 
   84   $accounting_product_mode = 
'ACCOUNTANCY_SELL';
 
   87 $limit = 
GETPOST(
'limit', 
'int') ?
GETPOST(
'limit', 
'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
 
   88 $sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
   89 $sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
   91 if (empty($page) || $page == -1) {
 
   94 $offset = $limit * $page;
 
   95 $pageprev = $page - 1;
 
   96 $pagenext = $page + 1;
 
  104 if (empty($action)) {
 
  108 $arrayfields = array();
 
  110 $accounting_product_modes = array(
 
  112   'ACCOUNTANCY_SELL_INTRA',
 
  113   'ACCOUNTANCY_SELL_EXPORT',
 
  115   'ACCOUNTANCY_BUY_INTRA',
 
  116   'ACCOUNTANCY_BUY_EXPORT' 
  119 if ($accounting_product_mode == 
'ACCOUNTANCY_BUY') {
 
  120   $accountancy_field_name = 
"accountancy_code_buy";
 
  121 } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_INTRA') {
 
  122   $accountancy_field_name = 
"accountancy_code_buy_intra";
 
  123 } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_EXPORT') {
 
  124   $accountancy_field_name = 
"accountancy_code_buy_export";
 
  125 } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL') {
 
  126   $accountancy_field_name = 
"accountancy_code_sell";
 
  127 } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL_INTRA') {
 
  128   $accountancy_field_name = 
"accountancy_code_sell_intra";
 
  130   $accountancy_field_name = 
"accountancy_code_sell_export";
 
  137 if (
GETPOST(
'cancel', 
'alpha')) {
 
  138   $action = 
'list'; $massaction = 
'';
 
  140 if (!
GETPOST(
'confirmmassaction', 
'alpha') && $massaction != 
'presend' && $massaction != 
'confirm_presend') {
 
  144 $parameters = array();
 
  145 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action); 
 
  151 if (
GETPOST(
'button_removefilter_x', 
'alpha') || 
GETPOST(
'button_removefilter.x', 
'alpha') || 
GETPOST(
'button_removefilter', 
'alpha')) { 
 
  152   $searchCategoryProductOperator = 0;
 
  153   $searchCategoryProductList = array();
 
  159   $search_onpurchase = 
'';
 
  160   $search_current_account = 
'';
 
  161   $search_current_account_valid = 
'-1';
 
  165 if ($action == 
'update') {
 
  166   if (!empty($btn_changetype)) {
 
  169     if (in_array($accounting_product_mode, $accounting_product_modes)) {
 
  170       if (!
dolibarr_set_const($db, 
'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 
'chaine', 0, 
'', $conf->entity)) {
 
  178   if (!empty($chk_prod) && $massaction === 
'changeaccount') {
 
  180     if (!empty($chk_prod) && in_array($accounting_product_mode, $accounting_product_modes)) {
 
  184       $arrayofdifferentselectedvalues = array();
 
  186       $cpt = 0; $ok = 0; $ko = 0;
 
  187       foreach ($chk_prod as $productid) {
 
  188         $accounting_account_id = 
GETPOST(
'codeventil_'.$productid);
 
  191         if ($accounting_account_id > 0) {
 
  192           $arrayofdifferentselectedvalues[$accounting_account_id] = $accounting_account_id;
 
  193           $result = $accounting->fetch($accounting_account_id, 
null, 1);
 
  197           $msg .= 
'<div><span style="color:red">'.$langs->trans(
"ErrorDB").
' : '.$langs->trans(
"Product").
' '.$productid.
' '.$langs->trans(
"NotVentilatedinAccount").
' : id='.$accounting_account_id.
'<br> <pre>'.$sql.
'</pre></span></div>';
 
  201           if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
 
  202             $sql_exists  = 
"SELECT rowid FROM " . MAIN_DB_PREFIX . 
"product_perentity";
 
  203             $sql_exists .= 
" WHERE fk_product = " . ((int) $productid) . 
" AND entity = " . ((int) $conf->entity);
 
  204             $resql_exists = $db->query($sql_exists);
 
  205             if (!$resql_exists) {
 
  206               $msg .= 
'<div><span style="color:red">'.$langs->trans(
"ErrorDB").
' : '.$langs->trans(
"Product").
' '.$productid.
' '.$langs->trans(
"NotVentilatedinAccount").
' : id='.$accounting_account_id.
'<br> <pre>'.$resql_exists.
'</pre></span></div>';
 
  209               $nb_exists = $db->num_rows($resql_exists);
 
  210               if ($nb_exists <= 0) {
 
  212                 $sql  = 
"INSERT INTO " . MAIN_DB_PREFIX . 
"product_perentity (fk_product, entity, " . $db->escape($accountancy_field_name) . 
")";
 
  213                 $sql .= 
" VALUES (" . ((int) $productid) . 
", " . ((int) $conf->entity) . 
", '" . $db->escape($accounting->account_number) . 
"')";
 
  215                 $obj_exists = $db->fetch_object($resql_exists);
 
  217                 $sql  = 
"UPDATE " . MAIN_DB_PREFIX . 
"product_perentity";
 
  218                 $sql .= 
" SET " . $accountancy_field_name . 
" = '" . $db->escape($accounting->account_number) . 
"'";
 
  219                 $sql .= 
" WHERE rowid = " . ((int) $obj_exists->rowid);
 
  223             $sql = 
" UPDATE ".MAIN_DB_PREFIX.
"product";
 
  224             $sql .= 
" SET ".$accountancy_field_name.
" = '".$db->escape($accounting->account_number).
"'";
 
  225             $sql .= 
" WHERE rowid = ".((int) $productid);
 
  228           dol_syslog(
"/accountancy/admin/productaccount.php", LOG_DEBUG);
 
  232           if ($db->query($sql)) {
 
  246       setEventMessages($langs->trans(
"XLineFailedToBeBinded", $ko), 
null, 
'errors');
 
  249       setEventMessages($langs->trans(
"XLineSuccessfullyBinded", $ok), 
null, 
'mesgs');
 
  267 $aarowid_servbuy            = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_SERVICE_BUY_ACCOUNT'), 1);
 
  268 $aarowid_servbuy_intra      = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT'), 1);
 
  269 $aarowid_servbuy_export     = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT'), 1);
 
  270 $aarowid_prodbuy            = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_PRODUCT_BUY_ACCOUNT'), 1);
 
  271 $aarowid_prodbuy_intra      = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT'), 1);
 
  272 $aarowid_prodbuy_export     = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT'), 1);
 
  273 $aarowid_servsell           = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_SERVICE_SOLD_ACCOUNT'), 1);
 
  274 $aarowid_servsell_intra     = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT'), 1);
 
  275 $aarowid_servsell_export    = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT'), 1);
 
  276 $aarowid_prodsell           = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT'), 1);
 
  277 $aarowid_prodsell_intra     = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT'), 1);
 
  278 $aarowid_prodsell_export    = $accounting->fetch(
'', 
getDolGlobalString(
'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT'), 1);
 
  280 $aacompta_servbuy           = 
getDolGlobalString(
'ACCOUNTING_SERVICE_BUY_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  281 $aacompta_servbuy_intra     = 
getDolGlobalString(
'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  282 $aacompta_servbuy_export    = 
getDolGlobalString(
'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  283 $aacompta_prodbuy           = 
getDolGlobalString(
'ACCOUNTING_PRODUCT_BUY_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  284 $aacompta_prodbuy_intra     = 
getDolGlobalString(
'ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  285 $aacompta_prodbuy_export    = 
getDolGlobalString(
'ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  286 $aacompta_servsell          = 
getDolGlobalString(
'ACCOUNTING_SERVICE_SOLD_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  287 $aacompta_servsell_intra    = 
getDolGlobalString(
'ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  288 $aacompta_servsell_export   = 
getDolGlobalString(
'ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  289 $aacompta_prodsell          = 
getDolGlobalString(
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  290 $aacompta_prodsell_intra    = 
getDolGlobalString(
'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  291 $aacompta_prodsell_export   = 
getDolGlobalString(
'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT', $langs->trans(
"CodeNotDef"));
 
  294 $title = $langs->trans(
"ProductsBinding");
 
  298 foreach ($searchCategoryProductList as $searchCategoryProduct) {
 
  299   $paramsCat .= 
"&search_category_product_list[]=".urlencode($searchCategoryProduct);
 
  302 llxHeader(
'', $title, $helpurl, 
'', 0, 0, array(), array(), $paramsCat, 
'');
 
  305 $pcgvercode = 
dol_getIdFromCode($db, $pcgverid, 
'accounting_system', 
'rowid', 
'pcg_version');
 
  306 if (empty($pcgvercode)) {
 
  307   $pcgvercode = $pcgverid;
 
  310 $sql = 
"SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
 
  311 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
 
  312   $sql .= 
" ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,";
 
  313   $sql .= 
" ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,";
 
  315   $sql .= 
" p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
 
  316   $sql .= 
" p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
 
  318 $sql .= 
" p.tms, p.fk_product_type as product_type,";
 
  319 $sql .= 
" aa.rowid as aaid";
 
  320 $sql .= 
" FROM ".MAIN_DB_PREFIX.
"product as p";
 
  321 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
 
  322   $sql .= 
" LEFT JOIN " . MAIN_DB_PREFIX . 
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
 
  323   $sql .= 
" LEFT JOIN " . MAIN_DB_PREFIX . 
"accounting_account as aa ON aa.account_number = ppe." . $accountancy_field_name . 
" AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . 
"'";
 
  325   $sql .= 
" LEFT JOIN " . MAIN_DB_PREFIX . 
"accounting_account as aa ON aa.account_number = p." . $accountancy_field_name . 
" AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . 
"'";
 
  327 if (!empty($searchCategoryProductList)) {
 
  328   $sql .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
"categorie_product as cp ON p.rowid = cp.fk_product"; 
 
  330 $sql .= 
' WHERE p.entity IN ('.getEntity(
'product').
')';
 
  331 if (strlen(trim($search_current_account))) {
 
  332   $sql .= 
natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? 
"p." : 
"ppe.") . $accountancy_field_name, $search_current_account);
 
  334 if ($search_current_account_valid == 
'withoutvalidaccount') {
 
  335   $sql .= 
" AND aa.account_number IS NULL";
 
  337 if ($search_current_account_valid == 
'withvalidaccount') {
 
  338   $sql .= 
" AND aa.account_number IS NOT NULL";
 
  340 $searchCategoryProductSqlList = array();
 
  341 if ($searchCategoryProductOperator == 1) {
 
  342   foreach ($searchCategoryProductList as $searchCategoryProduct) {
 
  343     if (intval($searchCategoryProduct) == -2) {
 
  344       $searchCategoryProductSqlList[] = 
"cp.fk_categorie IS NULL";
 
  345     } elseif (intval($searchCategoryProduct) > 0) {
 
  346       $searchCategoryProductSqlList[] = 
"cp.fk_categorie = ".$db->escape($searchCategoryProduct);
 
  349   if (!empty($searchCategoryProductSqlList)) {
 
  350     $sql .= 
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
 
  353   foreach ($searchCategoryProductList as $searchCategoryProduct) {
 
  354     if (intval($searchCategoryProduct) == -2) {
 
  355       $searchCategoryProductSqlList[] = 
"cp.fk_categorie IS NULL";
 
  356     } elseif (intval($searchCategoryProduct) > 0) {
 
  357       $searchCategoryProductSqlList[] = 
"p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).
")";
 
  360   if (!empty($searchCategoryProductSqlList)) {
 
  361     $sql .= 
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
 
  365 if (strlen(trim($search_ref))) {
 
  368 if (strlen(trim($search_label))) {
 
  371 if (strlen(trim($search_desc))) {
 
  374 if (strlen(trim($search_vat))) {
 
  377 if ($search_onsell != 
'' && $search_onsell != 
'-1') {
 
  380 if ($search_onpurchase != 
'' && $search_onpurchase != 
'-1') {
 
  384 $sql .= 
" GROUP BY p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
 
  385 $sql .= 
" p.fk_product_type,";
 
  387 $sql .= 
' aa.rowid,';
 
  388 if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
 
  389   $sql .= 
" p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export";
 
  391   $sql .= 
" ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export";
 
  394 $sql .= $db->order($sortfield, $sortorder);
 
  397 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
 
  398   $resql = $db->query($sql);
 
  406 $sql .= $db->plimit($limit + 1, $offset);
 
  408 dol_syslog(
"/accountancy/admin/productaccount.php", LOG_DEBUG);
 
  409 $resql = $db->query($sql);
 
  411   $num = $db->num_rows(
$resql);
 
  415   if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
 
  416     $param .= 
'&contextpage='.urlencode($contextpage);
 
  418   if ($limit > 0 && $limit != $conf->liste_limit) {
 
  419     $param .= 
'&limit='.urlencode($limit);
 
  421   if ($searchCategoryProductOperator == 1) {
 
  422     $param .= 
"&search_category_product_operator=".urlencode($searchCategoryProductOperator);
 
  424   foreach ($searchCategoryProductList as $searchCategoryProduct) {
 
  425     $param .= 
"&search_category_product_list[]=".urlencode($searchCategoryProduct);
 
  427   if ($search_ref > 0) {
 
  428     $param .= 
"&search_ref=".urlencode($search_ref);
 
  430   if ($search_label > 0) {
 
  431     $param .= 
"&search_label=".urlencode($search_label);
 
  433   if ($search_desc > 0) {
 
  434     $param .= 
"&search_desc=".urlencode($search_desc);
 
  436   if ($search_vat > 0) {
 
  437     $param .= 
'&search_vat='.urlencode($search_vat);
 
  439   if ($search_current_account > 0) {
 
  440     $param .= 
"&search_current_account=".urlencode($search_current_account);
 
  442   if ($search_current_account_valid && $search_current_account_valid != 
'-1') {
 
  443     $param .= 
"&search_current_account_valid=".urlencode($search_current_account_valid);
 
  445   if ($accounting_product_mode) {
 
  446     $param .= 
'&accounting_product_mode='.urlencode($accounting_product_mode);
 
  449   print 
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
 
  450   if ($optioncss != 
'') {
 
  451     print 
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
 
  453   print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  454   print 
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
 
  455   print 
'<input type="hidden" name="action" value="update">';
 
  456   print 
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
 
  457   print 
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
 
  459   print 
load_fiche_titre($langs->trans(
"ProductsBinding"), 
'', 
'title_accountancy');
 
  462   print 
'<span class="opacitymedium">'.$langs->trans(
"InitAccountancyDesc").
'</span><br>';
 
  466   print 
'<table class="noborder centpercent">';
 
  467   print 
'<tr class="liste_titre">';
 
  468   print 
'<td>'.$langs->trans(
'Options').
'</td><td>'.$langs->trans(
'Description').
'</td>';
 
  470   print 
'<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"'.($accounting_product_mode == 
'ACCOUNTANCY_SELL' ? 
' checked' : 
'').
'> '.$langs->trans(
'OptionModeProductSell').
'</td>';
 
  471   print 
'<td>'.$langs->trans(
'OptionModeProductSellDesc');
 
  472   print 
"</td></tr>\n";
 
  473   if ($mysoc->isInEEC()) {
 
  474     print 
'<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_INTRA"'.($accounting_product_mode == 
'ACCOUNTANCY_SELL_INTRA' ? 
' checked' : 
'').
'> '.$langs->trans(
'OptionModeProductSellIntra').
'</td>';
 
  475     print 
'<td>'.$langs->trans(
'OptionModeProductSellIntraDesc');
 
  476     print 
"</td></tr>\n";
 
  478   print 
'<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_EXPORT"'.($accounting_product_mode == 
'ACCOUNTANCY_SELL_EXPORT' ? 
' checked' : 
'').
'> '.$langs->trans(
'OptionModeProductSellExport').
'</td>';
 
  479   print 
'<td>'.$langs->trans(
'OptionModeProductSellExportDesc');
 
  480   print 
"</td></tr>\n";
 
  481   print 
'<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"'.($accounting_product_mode == 
'ACCOUNTANCY_BUY' ? 
' checked' : 
'').
'> '.$langs->trans(
'OptionModeProductBuy').
'</td>';
 
  482   print 
'<td>'.$langs->trans(
'OptionModeProductBuyDesc').
"</td></tr>\n";
 
  483   if ($mysoc->isInEEC()) {
 
  484     print 
'<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_INTRA"'.($accounting_product_mode == 
'ACCOUNTANCY_BUY_INTRA' ? 
' checked' : 
'').
'> '.$langs->trans(
'OptionModeProductBuyIntra').
'</td>';
 
  485     print 
'<td>'.$langs->trans(
'OptionModeProductBuyDesc').
"</td></tr>\n";
 
  487   print 
'<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_EXPORT"'.($accounting_product_mode == 
'ACCOUNTANCY_BUY_EXPORT' ? 
' checked' : 
'').
'> '.$langs->trans(
'OptionModeProductBuyExport').
'</td>';
 
  488   print 
'<td>'.$langs->trans(
'OptionModeProductBuyDesc').
"</td></tr>\n";
 
  491   print 
'<div class="center"><input type="submit" class="button" value="'.$langs->trans(
'Refresh').
'" name="changetype"></div>';
 
  498   $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
 
  499   $selectedfields = 
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage); 
 
  501   if ($massaction !== 
'set_default_account') {
 
  502     $arrayofmassactions = array(
 
  503       'changeaccount'=>
img_picto(
'', 
'check', 
'class="pictofixedwidth"').$langs->trans(
"Save")
 
  504       ,
'set_default_account'=>
img_picto(
'', 
'check', 
'class="pictofixedwidth"').$langs->trans(
"ConfirmPreselectAccount")
 
  506     $massactionbutton = 
$form->selectMassAction(
'', $arrayofmassactions, 1);
 
  509   $buttonsave = 
'<input type="submit" class="button button-save" id="changeaccount" name="changeaccount" value="'.$langs->trans(
"Save").
'">';
 
  512   $texte = $langs->trans(
"ListOfProductsServices");
 
  513   print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, 
$nbtotalofrecords, 
'', 0, 
'', 
'', $limit, 0, 0, 1);
 
  515   if ($massaction == 
'set_default_account') {
 
  516     $formquestion[]=array(
'type' => 
'other',
 
  517       'name' => 
'set_default_account',
 
  518       'label' => $langs->trans(
"AccountancyCode"),
 
  519       'value' => 
$form->select_account(
'', 
'default_account', 1, array(), 0, 0, 
'maxwidth200 maxwidthonsmartphone', 
'cachewithshowemptyone'));
 
  520     print 
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmPreselectAccount"), $langs->trans(
"ConfirmPreselectAccountQuestion", count($chk_prod)), 
"confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1);
 
  525   if (
isModEnabled(
'categorie') && $user->hasRight(
'categorie', 
'lire')) {
 
  526     $moreforfilter .= 
'<div class="divsearchfield">';
 
  527     $moreforfilter .= 
img_picto($langs->trans(
'Categories'), 
'category', 
'class="pictofixedwidth"');
 
  528     $categoriesProductArr = 
$form->select_all_categories(Categorie::TYPE_PRODUCT, 
'', 
'', 64, 0, 1);
 
  529     $categoriesProductArr[-2] = 
'- '.$langs->trans(
'NotCategorized').
' -';
 
  530     $moreforfilter .= 
Form::multiselectarray(
'search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 
'minwidth300');
 
  531     $moreforfilter .= 
' <input type="checkbox" class="valignmiddle" name="search_category_product_operator" value="1"'.($searchCategoryProductOperator == 1 ? 
' checked="checked"' : 
'').
'/> <span class="none">'.$langs->trans(
'UseOrOperatorForCategories').
'</span>';
 
  532     $moreforfilter .= 
'</div>';
 
  536   if (
isModEnabled(
'variants') && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
 
  537     $moreforfilter .= 
'<div class="divsearchfield">';
 
  538     $moreforfilter .= 
'<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"'.($show_childproducts ? 
'checked="checked"' : 
'').
'>';
 
  539     $moreforfilter .= 
' <label for="search_show_childproducts">'.$langs->trans(
'ShowChildProducts').
'</label>';
 
  540     $moreforfilter .= 
'</div>';
 
  543   $parameters = array();
 
  544   $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters); 
 
  545   if (empty($reshook)) {
 
  546     $moreforfilter .= $hookmanager->resPrint;
 
  548     $moreforfilter = $hookmanager->resPrint;
 
  551   if ($moreforfilter) {
 
  552     print 
'<div class="liste_titre liste_titre_bydiv centpercent">';
 
  553     print $moreforfilter;
 
  557   print 
'<div class="div-table-responsive">';
 
  558   print 
'<table class="liste '.($moreforfilter ? 
"listwithfilterbefore" : 
"").
'">';
 
  560   print 
'<tr class="liste_titre_filter">';
 
  561   print 
'<td class="liste_titre"><input type="text" class="flat" size="8" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
 
  562   print 
'<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).
'"></td>';
 
  563   print 
'<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" size="5" name="search_vat" placeholder="%" value="'.dol_escape_htmltag($search_vat).
'"></td>';
 
  565   if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) {
 
  566     print 
'<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="'.dol_escape_htmltag($search_desc).
'"></td>';
 
  569   if ($accounting_product_mode == 
'ACCOUNTANCY_SELL' || $accounting_product_mode == 
'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 
'ACCOUNTANCY_SELL_EXPORT') {
 
  570     print 
'<td class="liste_titre center">'.$form->selectyesno(
'search_onsell', $search_onsell, 1, 
false, 1).
'</td>';
 
  573     print 
'<td class="liste_titre center">'.$form->selectyesno(
'search_onpurchase', $search_onpurchase, 1, 
false, 1).
'</td>';
 
  576   print 
'<td class="liste_titre">';
 
  577   print 
'<input type="text" class="flat" size="6" name="search_current_account" id="search_current_account" value="'.dol_escape_htmltag($search_current_account).
'">';
 
  578   $listofvals = array(
'withoutvalidaccount'=>$langs->trans(
"WithoutValidAccount"), 
'withvalidaccount'=>$langs->trans(
"WithValidAccount"));
 
  579   print 
' '.$langs->trans(
"or").
' '.
$form->selectarray(
'search_current_account_valid', $listofvals, $search_current_account_valid, 1);
 
  581   print 
'<td class="liste_titre"> </td>';
 
  582   print 
'<td class="center liste_titre">';
 
  583   $searchpicto = 
$form->showFilterButtons();
 
  588   print 
'<tr class="liste_titre">';
 
  591   if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) {
 
  592     print_liste_field_titre(
"Description", $_SERVER[
"PHP_SELF"], 
"p.description", 
"", $param, 
'', $sortfield, $sortorder);
 
  594   print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"], 
"p.tva_tx", 
"", $param, 
'', $sortfield, $sortorder, 
'right ');
 
  596   if ($accounting_product_mode == 
'ACCOUNTANCY_SELL' || $accounting_product_mode == 
'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 
'ACCOUNTANCY_SELL_EXPORT') {
 
  597     print_liste_field_titre(
"OnSell", $_SERVER[
"PHP_SELF"], 
"p.tosell", 
"", $param, 
'', $sortfield, $sortorder, 
'center ');
 
  599     print_liste_field_titre(
"OnBuy", $_SERVER[
"PHP_SELF"], 
"p.tobuy", 
"", $param, 
'', $sortfield, $sortorder, 
'center ');
 
  601   print_liste_field_titre(
"CurrentDedicatedAccountingAccount", $_SERVER[
"PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? 
"p." : 
"ppe.") . $accountancy_field_name, 
"", $param, 
'', $sortfield, $sortorder);
 
  603   $clickpitco = 
$form->showCheckAddButtons(
'checkforselect', 1);
 
  607   $product_static = 
new Product($db);
 
  610   while ($i < min($num, $limit)) {
 
  611     $obj = $db->fetch_object(
$resql);
 
  614     $product_static->ref = $obj->ref;
 
  615     $product_static->id = $obj->rowid;
 
  616     $product_static->type = $obj->product_type;
 
  617     $product_static->label = $obj->label;
 
  618     $product_static->description = $obj->description;
 
  619     $product_static->status = $obj->tosell;
 
  620     $product_static->status_buy = $obj->tobuy;
 
  623     if ($obj->product_type == 0) {
 
  624       if ($accounting_product_mode == 
'ACCOUNTANCY_SELL') {
 
  625         $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  626         $compta_prodsell_id = $aarowid_prodsell;
 
  627       } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL_INTRA') {
 
  628         $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  629         $compta_prodsell_id = $aarowid_prodsell_intra;
 
  630       } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL_EXPORT') {
 
  631         $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  632         $compta_prodsell_id = $aarowid_prodsell_export;
 
  634         $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  635         $compta_prodsell_id = $aarowid_prodsell;
 
  638       if ($accounting_product_mode == 
'ACCOUNTANCY_SELL') {
 
  639         $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  640         $compta_prodsell_id = $aarowid_servsell;
 
  641       } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL_INTRA') {
 
  642         $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  643         $compta_prodsell_id = $aarowid_servsell_intra;
 
  644       } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL_EXPORT') {
 
  645         $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  646         $compta_prodsell_id = $aarowid_servsell_export;
 
  648         $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  649         $compta_prodsell_id = $aarowid_servsell;
 
  654     if ($obj->product_type == 0) {
 
  655       if ($accounting_product_mode == 
'ACCOUNTANCY_BUY') {
 
  656         $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  657         $compta_prodbuy_id = $aarowid_prodbuy;
 
  658       } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_INTRA') {
 
  659         $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  660         $compta_prodbuy_id = $aarowid_prodbuy_intra;
 
  661       } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_EXPORT') {
 
  662         $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  663         $compta_prodbuy_id = $aarowid_prodbuy_export;
 
  665         $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  666         $compta_prodbuy_id = $aarowid_prodbuy;
 
  669       if ($accounting_product_mode == 
'ACCOUNTANCY_BUY') {
 
  670         $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  671         $compta_prodbuy_id = $aarowid_servbuy;
 
  672       } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_INTRA') {
 
  673         $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  674         $compta_prodbuy_id = $aarowid_servbuy_intra;
 
  675       } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_EXPORT') {
 
  676         $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  677         $compta_prodbuy_id = $aarowid_servbuy_export;
 
  679         $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans(
"CodeNotDef"));
 
  680         $compta_prodbuy_id = $aarowid_servbuy;
 
  684     print 
'<tr class="oddeven">';
 
  687     print $product_static->getNomUrl(1);
 
  690     print 
'<td class="left">'.$obj->label.
'</td>';
 
  692     if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) {
 
  696       $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
 
  697       print 
'<td>'.nl2br(
dol_trunc($obj->description, $trunclength)).
'</td>';
 
  701     print 
'<td class="right">';
 
  706     if ($accounting_product_mode == 
'ACCOUNTANCY_SELL' || $accounting_product_mode == 
'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 
'ACCOUNTANCY_SELL_EXPORT') {
 
  707       print 
'<td class="center">'.$product_static->getLibStatut(3, 0).
'</td>';
 
  709       print 
'<td class="center">'.$product_static->getLibStatut(3, 1).
'</td>';
 
  713     print 
'<td class="left">';
 
  714     if ($accounting_product_mode == 
'ACCOUNTANCY_BUY') {
 
  716       if ($obj->accountancy_code_buy && empty($obj->aaid)) {
 
  717         print 
' '.img_warning($langs->trans(
"ValueNotIntoChartOfAccount"));
 
  719     } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_INTRA') {
 
  721       if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) {
 
  722         print 
' '.img_warning($langs->trans(
"ValueNotIntoChartOfAccount"));
 
  724     } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_EXPORT') {
 
  726       if ($obj->accountancy_code_buy_export && empty($obj->aaid)) {
 
  727         print 
' '.img_warning($langs->trans(
"ValueNotIntoChartOfAccount"));
 
  729     } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL') {
 
  731       if ($obj->accountancy_code_sell && empty($obj->aaid)) {
 
  732         print 
' '.img_warning($langs->trans(
"ValueNotIntoChartOfAccount"));
 
  734     } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL_INTRA') {
 
  736       if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) {
 
  737         print 
' '.img_warning($langs->trans(
"ValueNotIntoChartOfAccount"));
 
  741       if ($obj->accountancy_code_sell_export && empty($obj->aaid)) {
 
  742         print 
' '.img_warning($langs->trans(
"ValueNotIntoChartOfAccount"));
 
  749     if ($accounting_product_mode == 
'ACCOUNTANCY_BUY') {
 
  751       print 
'<td class="left">';
 
  753       if (empty($defaultvalue)) {
 
  754         $defaultvalue = $compta_prodbuy;
 
  757       if (!empty($obj->aaid)) {
 
  760       print 
$form->select_account(($default_account > 0 && $confirm === 
'yes' && in_array($product_static->id, $chk_prod)) ? $default_account : $defaultvalue, 
'codeventil_'.$product_static->id, 1, array(), 1, 0, 
'maxwidth300 maxwidthonsmartphone productforselect');
 
  762     } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_INTRA') {
 
  764       print 
'<td class="left">';
 
  766       if (empty($defaultvalue)) {
 
  767         $defaultvalue = $compta_prodbuy;
 
  771       if (!empty($obj->aaid)) {
 
  774       print 
$form->select_account(($default_account > 0 && $confirm === 
'yes' && in_array($product_static->id, $chk_prod)) ? $default_account : $defaultvalue, 
'codeventil_'.$product_static->id, 1, array(), 1, 0, 
'maxwidth300 maxwidthonsmartphone productforselect');
 
  776     } elseif ($accounting_product_mode == 
'ACCOUNTANCY_BUY_EXPORT') {
 
  778       print 
'<td class="left">';
 
  780       if (empty($defaultvalue)) {
 
  781         $defaultvalue = $compta_prodbuy;
 
  785       if (!empty($obj->aaid)) {
 
  788       print 
$form->select_account(($default_account > 0 && $confirm === 
'yes' && in_array($product_static->id, $chk_prod)) ? $default_account : $defaultvalue, 
'codeventil_'.$product_static->id, 1, array(), 1, 0, 
'maxwidth300 maxwidthonsmartphone productforselect');
 
  790     } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL') {
 
  792       print 
'<td class="left">';
 
  794       if (empty($defaultvalue)) {
 
  795         $defaultvalue = $compta_prodsell;
 
  799       if (!empty($obj->aaid)) {
 
  802       print 
$form->select_account(($default_account > 0 && $confirm === 
'yes' && in_array($product_static->id, $chk_prod)) ? $default_account : $defaultvalue, 
'codeventil_'.$product_static->id, 1, array(), 1, 0, 
'maxwidth300 maxwidthonsmartphone productforselect');
 
  804     } elseif ($accounting_product_mode == 
'ACCOUNTANCY_SELL_INTRA') {
 
  806       print 
'<td class="left">';
 
  808       if (empty($defaultvalue)) {
 
  809         $defaultvalue = $compta_prodsell;
 
  813       if (!empty($obj->aaid)) {
 
  816       print 
$form->select_account(($default_account > 0 && $confirm === 
'yes' && in_array($product_static->id, $chk_prod)) ? $default_account : $defaultvalue, 
'codeventil_'.$product_static->id, 1, array(), 1, 0, 
'maxwidth300 maxwidthonsmartphone productforselect');
 
  820       print 
'<td class="left">';
 
  822       if (empty($defaultvalue)) {
 
  823         $defaultvalue = $compta_prodsell;
 
  826       if (!empty($obj->aaid)) {
 
  829       print 
$form->select_account(($default_account > 0 && $confirm === 
'yes' && in_array($product_static->id, $chk_prod)) ? $default_account : $defaultvalue, 
'codeventil_'.$product_static->id, 1, array(), 1, 0, 
'maxwidth300 maxwidthonsmartphone productforselect');
 
  833     if (!empty($chk_prod)) {
 
  835       if (in_array($product_static->id, $chk_prod)) {
 
  841     print 
'<td class="center">';
 
  842     print 
'<input type="checkbox" class="checkforselect productforselectcodeventil_'.$product_static->id.
'" name="chk_prod[]" '.($ischecked ? 
"checked" : 
"").
' value="'.$obj->rowid.
'"/></td>';
 
  849   print 
'<script type="text/javascript"> 
  850         jQuery(document).ready(function() { 
  851           function init_savebutton() 
  853               console.log("We check if at least one line is checked") 
  855           atleastoneselected=0; 
  856           jQuery(".checkforselect").each(function( index ) { 
  857             /* console.log( index + ": " + $( this ).text() ); */ 
  858             if ($(this).is(\':checked\')) atleastoneselected++; 
  861               if (atleastoneselected) jQuery("#changeaccount").removeAttr(\'disabled\'); 
  862               else jQuery("#changeaccount").attr(\'disabled\',\'disabled\'); 
  863               if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'button\'); 
  864               else jQuery("#changeaccount").attr(\'class\',\'button\'); 
  867           jQuery(".checkforselect").change(function() { 
  870           jQuery(".productforselect").change(function() { 
  871         console.log($(this).attr("id")+" "+$(this).val()); 
  872         if ($(this).val() && $(this).val() != -1) { 
  873           $(".productforselect"+$(this).attr("id")).prop(\'checked\', true); 
  875           $(".productforselect"+$(this).attr("id")).prop(\'checked\', false); 
  882             jQuery("#search_current_account").keyup(function() { 
  883             if (jQuery("#search_current_account").val() != \'\') 
  885                     console.log("We set a value of account to search "+jQuery("#search_current_account").val()+", so we disable the other search criteria on account"); 
  886                     jQuery("#search_current_account_valid").val(-1); 
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
 
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
 
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
 
Class to manage accounting accounts.
 
Class to manage products or services.
 
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
 
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
 
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
 
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
 
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
 
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
 
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
 
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
 
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
 
isModEnabled($module)
Is Dolibarr module enabled.
 
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
 
$nbtotalofrecords
Count total nb of records.
 
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.