|
|
|
@@ -40,6 +40,7 @@ $langs->load("companies");
|
|
|
|
$langs->load("compta");
|
|
|
|
$langs->load("compta");
|
|
|
|
$langs->load("main");
|
|
|
|
$langs->load("main");
|
|
|
|
$langs->load("accountancy");
|
|
|
|
$langs->load("accountancy");
|
|
|
|
|
|
|
|
$langs->load("products");
|
|
|
|
|
|
|
|
|
|
|
|
// Security check
|
|
|
|
// Security check
|
|
|
|
if (empty($conf->accounting->enabled)) {
|
|
|
|
if (empty($conf->accounting->enabled)) {
|
|
|
|
@@ -61,6 +62,10 @@ $changeaccount_sell = GETPOST('changeaccount_sell', 'array');
|
|
|
|
$search_ref = GETPOST('search_ref', 'alpha');
|
|
|
|
$search_ref = GETPOST('search_ref', 'alpha');
|
|
|
|
$search_label = GETPOST('search_label', 'alpha');
|
|
|
|
$search_label = GETPOST('search_label', 'alpha');
|
|
|
|
$search_desc = GETPOST('search_desc', 'alpha');
|
|
|
|
$search_desc = GETPOST('search_desc', 'alpha');
|
|
|
|
|
|
|
|
$search_current_account = GETPOST('search_current_account', 'alpha');
|
|
|
|
|
|
|
|
$search_current_account_valid = GETPOST('search_current_account_valid', 'alpha');
|
|
|
|
|
|
|
|
if ($search_current_account_valid == '') $search_current_account_valid='withoutvalidaccount';
|
|
|
|
|
|
|
|
|
|
|
|
$accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
|
|
|
|
$accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
|
|
|
|
$btn_changeaccount = GETPOST('changeaccount');
|
|
|
|
$btn_changeaccount = GETPOST('changeaccount');
|
|
|
|
$btn_changetype = GETPOST('changetype');
|
|
|
|
$btn_changetype = GETPOST('changetype');
|
|
|
|
@@ -85,12 +90,21 @@ $arrayfields=array();
|
|
|
|
* Actions
|
|
|
|
* Actions
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (GETPOST('cancel')) { $action='list'; $massaction=''; }
|
|
|
|
|
|
|
|
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$parameters=array();
|
|
|
|
|
|
|
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
|
|
|
|
|
|
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
|
|
|
|
|
|
|
|
|
// Purge search criteria
|
|
|
|
// Purge search criteria
|
|
|
|
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
|
|
|
|
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$search_ref = '';
|
|
|
|
$search_ref = '';
|
|
|
|
$search_label = '';
|
|
|
|
$search_label = '';
|
|
|
|
$search_desc = '';
|
|
|
|
$search_desc = '';
|
|
|
|
|
|
|
|
$search_current_account = '';
|
|
|
|
|
|
|
|
$search_current_account_valid = '-1';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Sales or Purchase mode ?
|
|
|
|
// Sales or Purchase mode ?
|
|
|
|
@@ -189,23 +203,38 @@ $aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ?
|
|
|
|
|
|
|
|
|
|
|
|
llxHeader('', $langs->trans("ProductsBinding"));
|
|
|
|
llxHeader('', $langs->trans("ProductsBinding"));
|
|
|
|
|
|
|
|
|
|
|
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
|
|
|
$pcgverid = $conf->global->CHARTOFACCOUNTS;
|
|
|
|
|
|
|
|
$pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
|
|
|
|
|
|
|
|
if (empty($pcgvercode)) $pcgvercode=$pcgverid;
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT p.rowid, p.ref, p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type";
|
|
|
|
$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type,";
|
|
|
|
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
|
|
|
|
$sql.= " aa.rowid as aaid";
|
|
|
|
$sql .= " WHERE (";
|
|
|
|
$sql.= " FROM " . MAIN_DB_PREFIX . "product as p";
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') {
|
|
|
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
|
|
|
|
$sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL";
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
|
|
|
$sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN
|
|
|
|
$sql.=" p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
|
|
|
|
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL ";
|
|
|
|
|
|
|
|
$sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN
|
|
|
|
|
|
|
|
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$sql .= ")";
|
|
|
|
else
|
|
|
|
if (! empty($conf->multicompany->enabled)) {
|
|
|
|
{
|
|
|
|
$sql.= ' AND p.entity IN ('.getEntity('product', 1).')';
|
|
|
|
$sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
|
|
|
|
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
|
|
|
|
|
|
|
if (strlen(trim($search_current_account))) {
|
|
|
|
|
|
|
|
$sql .= natural_search("p.accountancy_code_buy",$search_current_account);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (strlen(trim($search_current_account))) {
|
|
|
|
|
|
|
|
$sql .= natural_search("p.accountancy_code_sell",$search_current_account);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($search_current_account_valid == 'withoutvalidaccount')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$sql .= " AND aa.account_number IS NULL";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($search_current_account_valid == 'withvalidaccount')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$sql .= " AND aa.account_number IS NOT NULL";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Add search filter like
|
|
|
|
// Add search filter like
|
|
|
|
if (strlen(trim($search_ref))) {
|
|
|
|
if (strlen(trim($search_ref))) {
|
|
|
|
@@ -218,6 +247,7 @@ if (strlen(trim($search_desc))) {
|
|
|
|
$sql .= natural_search("p.description",$search_desc);
|
|
|
|
$sql .= natural_search("p.description",$search_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$sql .= $db->order($sortfield, $sortorder);
|
|
|
|
$sql .= $db->order($sortfield, $sortorder);
|
|
|
|
|
|
|
|
|
|
|
|
$nbtotalofrecords = 0;
|
|
|
|
$nbtotalofrecords = 0;
|
|
|
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
|
|
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -236,9 +266,11 @@ if ($result)
|
|
|
|
$param='';
|
|
|
|
$param='';
|
|
|
|
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
|
|
|
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
|
|
|
if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref);
|
|
|
|
if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref);
|
|
|
|
if ($search_label > 0) $param.="&search_desc=".urlencode($search_label);
|
|
|
|
if ($search_label > 0) $param.="&search_desc=".urlencode($search_label);
|
|
|
|
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
|
|
|
|
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
|
|
|
|
|
|
|
|
if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account);
|
|
|
|
|
|
|
|
if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid);
|
|
|
|
|
|
|
|
|
|
|
|
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
|
|
|
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
|
|
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
|
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
|
|
@@ -260,11 +292,10 @@ if ($result)
|
|
|
|
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
|
|
|
|
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
|
|
|
|
print "</tr>\n";
|
|
|
|
print "</tr>\n";
|
|
|
|
print '<tr ' . $bc[false] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>';
|
|
|
|
print '<tr ' . $bc[false] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>';
|
|
|
|
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductSellDesc'));
|
|
|
|
print '<td>'.$langs->trans('OptionModeProductSellDesc');
|
|
|
|
print "</td></tr>\n";
|
|
|
|
print "</td></tr>\n";
|
|
|
|
print '<tr ' . $bc[true] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>';
|
|
|
|
print '<tr ' . $bc[true] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>';
|
|
|
|
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductBuyDesc')) . "</td></tr>\n";
|
|
|
|
print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
|
|
|
|
|
|
|
|
|
|
|
|
print "</table>\n";
|
|
|
|
print "</table>\n";
|
|
|
|
|
|
|
|
|
|
|
|
print '<div align="center"><input type="submit" class="button" value="' . $langs->trans('Refresh') . '" name="changetype"></div>';
|
|
|
|
print '<div align="center"><input type="submit" class="button" value="' . $langs->trans('Refresh') . '" name="changetype"></div>';
|
|
|
|
@@ -277,7 +308,7 @@ if ($result)
|
|
|
|
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
|
|
|
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
|
|
|
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
|
|
|
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
|
|
|
|
|
|
|
|
|
|
|
$texte=$langs->trans("ListOfProductsWithoutAccountingAccount");
|
|
|
|
$texte=$langs->trans("ListOfProductsServices");
|
|
|
|
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
|
|
|
|
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
|
|
|
|
|
|
|
|
|
|
|
|
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
|
|
|
|
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
|
|
|
|
@@ -285,37 +316,54 @@ if ($result)
|
|
|
|
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
|
|
|
|
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
|
|
|
|
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
|
|
|
|
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
|
|
|
|
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
|
|
|
|
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
|
|
|
|
/*
|
|
|
|
print_liste_field_titre($langs->trans("OnSell"), $_SERVER["PHP_SELF"], "p.tosell", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
|
|
|
print_liste_field_titre($langs->trans("OnBuy"), $_SERVER["PHP_SELF"], "p.tobuy", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
|
|
print_liste_field_titre($langs->trans("Accountancy_code_buy"));
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
|
|
|
} else {
|
|
|
|
$fieldtosortaccount="p.accountancy_code_buy";
|
|
|
|
print_liste_field_titre($langs->trans("Accountancy_code_sell"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else $fieldtosortaccount="p.accountancy_code_sell";
|
|
|
|
*/
|
|
|
|
print_liste_field_titre($langs->trans("CurrentDedicatedAccountingAccount"), $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder);
|
|
|
|
print_liste_field_titre($langs->trans("AccountAccounting"));
|
|
|
|
print_liste_field_titre($langs->trans("AssignDedicatedAccountingAccount"));
|
|
|
|
//print_liste_field_titre($langs->trans("Modify") . '<br><label id="select-all">' . $langs->trans('All') . '</label> / <label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"');
|
|
|
|
|
|
|
|
print_liste_field_titre('', '', '', '', '', 'align="center"');
|
|
|
|
print_liste_field_titre('', '', '', '', '', 'align="center"');
|
|
|
|
print '</tr>';
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
|
|
|
|
print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
|
|
|
|
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
|
|
|
|
print '<td class="liste_titre"><input type="text" class="flat" size="14" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
|
|
|
|
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
|
|
|
|
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
|
|
|
|
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"> </td>';
|
|
|
|
// On sell
|
|
|
|
|
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
|
|
|
|
|
// On buy
|
|
|
|
|
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
|
|
|
|
|
// Current account
|
|
|
|
|
|
|
|
print '<td class="liste_titre">';
|
|
|
|
|
|
|
|
print '<input type="text" class="flat" size="6" name="search_current_account" value="' . dol_escape_htmltag($search_current_account) . '">';
|
|
|
|
|
|
|
|
$listofvals=array('withoutvalidaccount'=>$langs->trans("WithoutValidAccount"), 'withvalidaccount'=>$langs->trans("WithValidAccount"));
|
|
|
|
|
|
|
|
print ' '.$langs->trans("or").' '.$form->selectarray('search_current_account_valid', $listofvals, $search_current_account_valid, 1);
|
|
|
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
|
|
print '<td class="liste_titre"> </td>';
|
|
|
|
print '<td align="right" class="liste_titre">';
|
|
|
|
print '<td align="right" class="liste_titre">';
|
|
|
|
$searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1);
|
|
|
|
$searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1);
|
|
|
|
print $searchpitco;
|
|
|
|
print $searchpitco;
|
|
|
|
print '</td>';
|
|
|
|
print '</td>';
|
|
|
|
print '</tr>';
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
|
|
$var = true;
|
|
|
|
$product_static = new Product($db);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$var = true;
|
|
|
|
|
|
|
|
$i=0;
|
|
|
|
while ($i < min($num,$limit))
|
|
|
|
while ($i < min($num,$limit))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$obj = $db->fetch_object($result);
|
|
|
|
$obj = $db->fetch_object($result);
|
|
|
|
$var = ! $var;
|
|
|
|
|
|
|
|
|
|
|
|
// Ref produit as link
|
|
|
|
$compta_prodsell = $obj->accountancy_code_sell;
|
|
|
|
$product_static->ref = $obj->ref;
|
|
|
|
|
|
|
|
$product_static->id = $obj->rowid;
|
|
|
|
|
|
|
|
$product_static->type = $obj->product_type;
|
|
|
|
|
|
|
|
$product_static->label = $obj->label;
|
|
|
|
|
|
|
|
$product_static->description = $obj->description;
|
|
|
|
|
|
|
|
$product_static->status = $obj->tosell;
|
|
|
|
|
|
|
|
$product_static->status_buy = $obj->tobuy;
|
|
|
|
|
|
|
|
|
|
|
|
if ($obj->product_type == 0) {
|
|
|
|
if ($obj->product_type == 0) {
|
|
|
|
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
|
|
|
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
|
|
|
@@ -325,8 +373,6 @@ if ($result)
|
|
|
|
$compta_prodsell_id = $aarowid_servsell;
|
|
|
|
$compta_prodsell_id = $aarowid_servsell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$compta_prodbuy = $obj->accountancy_code_buy;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($obj->product_type == 0) {
|
|
|
|
if ($obj->product_type == 0) {
|
|
|
|
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
|
|
|
$compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
|
|
|
$compta_prodbuy_id = $aarowid_prodbuy;
|
|
|
|
$compta_prodbuy_id = $aarowid_prodbuy;
|
|
|
|
@@ -335,30 +381,15 @@ if ($result)
|
|
|
|
$compta_prodbuy_id = $aarowid_servbuy;
|
|
|
|
$compta_prodbuy_id = $aarowid_servbuy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$product_static = new Product($db);
|
|
|
|
$var = ! $var;
|
|
|
|
|
|
|
|
|
|
|
|
print '<tr'. $bc[$var].'>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '<tr '. $bc[$var].'>';
|
|
|
|
print '<tr '. $bc[$var].'>';
|
|
|
|
|
|
|
|
|
|
|
|
// Ref produit as link
|
|
|
|
|
|
|
|
$product_static->ref = $obj->ref;
|
|
|
|
|
|
|
|
$product_static->id = $obj->rowid;
|
|
|
|
|
|
|
|
$product_static->type = $obj->type;
|
|
|
|
|
|
|
|
$product_static->label = $obj->label;
|
|
|
|
|
|
|
|
$product_static->description = $obj->description;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '<td>';
|
|
|
|
print '<td>';
|
|
|
|
if ($product_static->id)
|
|
|
|
print $product_static->getNomUrl(1);
|
|
|
|
print $product_static->getNomUrl(1);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
print '- ';
|
|
|
|
|
|
|
|
print '</td>';
|
|
|
|
print '</td>';
|
|
|
|
|
|
|
|
|
|
|
|
print '<td align="left">'.$obj->label.'</td>';
|
|
|
|
print '<td align="left">'.$obj->label.'</td>';
|
|
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
|
|
|
|
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO ADJUST DESCRIPTION SIZE
|
|
|
|
// TODO ADJUST DESCRIPTION SIZE
|
|
|
|
@@ -368,24 +399,43 @@ if ($result)
|
|
|
|
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
|
|
|
|
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Accounting account buy
|
|
|
|
print '<td align="center">'.$product_static->getLibStatut(3, 0).'</td>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '<td align="center">'.$product_static->getLibStatut(3, 1).'</td>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Current accounting account
|
|
|
|
|
|
|
|
print '<td align="left">';
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
|
|
|
// print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
|
|
|
|
print length_accountg($obj->accountancy_code_buy);
|
|
|
|
// TODO: replace by select
|
|
|
|
if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
|
|
|
// print '<td align="left">' . $compta_prodbuy . '</td>';
|
|
|
|
}
|
|
|
|
// TODO: we shoul set a user defined value to adjust user square / wide screen size
|
|
|
|
else
|
|
|
|
// $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
|
|
|
|
{
|
|
|
|
|
|
|
|
print length_accountg($obj->accountancy_code_sell);
|
|
|
|
|
|
|
|
if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Dedicated account
|
|
|
|
|
|
|
|
$defaultvalue='';
|
|
|
|
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
|
|
|
|
|
|
|
// Accounting account buy
|
|
|
|
print '<td align="left">';
|
|
|
|
print '<td align="left">';
|
|
|
|
print $form->select_account($compta_prodbuy_id, 'codeventil_' . $product_static->id, 1);
|
|
|
|
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
|
|
|
|
|
|
|
|
if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy;
|
|
|
|
|
|
|
|
$codesell=length_accountg($obj->accountancy_code_buy);
|
|
|
|
|
|
|
|
if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
|
|
|
|
|
|
|
|
print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1);
|
|
|
|
print '</td>';
|
|
|
|
print '</td>';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Accounting account sell
|
|
|
|
// Accounting account sell
|
|
|
|
// print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
|
|
|
|
|
|
|
|
// TODO: replace by select
|
|
|
|
|
|
|
|
// TODO: we shoul set a user defined value to adjust user square / wide screen size
|
|
|
|
|
|
|
|
// $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
|
|
|
|
|
|
|
|
print '<td align="left">';
|
|
|
|
print '<td align="left">';
|
|
|
|
print $form->select_account($compta_prodsell_id, 'codeventil_' . $product_static->id, 1);
|
|
|
|
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
|
|
|
|
|
|
|
|
if (empty($defaultvalue)) $defaultvalue=$compta_prodsell;
|
|
|
|
|
|
|
|
$codesell=length_accountg($obj->accountancy_code_sell);
|
|
|
|
|
|
|
|
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
|
|
|
|
|
|
|
|
if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
|
|
|
|
|
|
|
|
print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1);
|
|
|
|
print '</td>';
|
|
|
|
print '</td>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -397,7 +447,34 @@ if ($result)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print '</table>';
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
|
|
print '<br><div align="center"><input type="submit" class="butAction" name="changeaccount" value="' . $langs->trans("Save") . '"></div>';
|
|
|
|
// Example : Adding jquery code
|
|
|
|
|
|
|
|
print '<script type="text/javascript" language="javascript">
|
|
|
|
|
|
|
|
jQuery(document).ready(function() {
|
|
|
|
|
|
|
|
function init_savebutton()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
console.log("We check if at least one line is checked")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
atleastoneselected=0;
|
|
|
|
|
|
|
|
jQuery(".checkforselect").each(function( index ) {
|
|
|
|
|
|
|
|
/* console.log( index + ": " + $( this ).text() ); */
|
|
|
|
|
|
|
|
if ($(this).is(\':checked\')) atleastoneselected++;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (atleastoneselected) jQuery("#changeaccount").removeAttr(\'disabled\');
|
|
|
|
|
|
|
|
else jQuery("#changeaccount").attr(\'disabled\',\'disabled\');
|
|
|
|
|
|
|
|
if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'butAction\');
|
|
|
|
|
|
|
|
else jQuery("#changeaccount").attr(\'class\',\'butActionRefused\');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery(".checkforselect, #checkallactions").click(function() {
|
|
|
|
|
|
|
|
init_savebutton();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init_savebutton();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '<br><div align="center"><input type="submit" class="butAction" id="changeaccount" name="changeaccount" value="' . $langs->trans("Save") . '"></div>';
|
|
|
|
|
|
|
|
|
|
|
|
print '</form>';
|
|
|
|
print '</form>';
|
|
|
|
|
|
|
|
|
|
|
|
|