Merge pull request #12427 from Dolibarr/scrutinizer-patch-3

Scrutinizer Auto-Fixes
This commit is contained in:
Laurent Destailleur 2019-11-14 08:49:53 +01:00 committed by GitHub
commit 614faa07c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 2194 additions and 2194 deletions

View File

@ -27,13 +27,13 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
@ -41,16 +41,16 @@ if (empty($conf->accounting->enabled)) {
}
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else
{
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
@ -77,20 +77,20 @@ if ($action == 'clean' || $action == 'validatehistory')
{
// Clean database
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd";
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd";
$sql1 .= " SET fk_code_ventilation = 0";
$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN';
$sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture WHERE entity = '.$conf->entity.')';
$sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt';
$sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture WHERE entity = '.$conf->entity.')';
$sql1 .= ' AND fk_code_ventilation <> 0';
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -121,26 +121,26 @@ if ($action == 'validatehistory') {
// Customer Invoice lines (must be same request than into page list.php for manual binding)
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,";
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
$sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
$sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql.= " co.code as country_code, co.label as country_label,";
$sql.= " s.tva_intra";
$sql.= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity;
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity;
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity;
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql.= " AND l.product_type <= 2";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
$sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2";
dol_syslog('htdocs/accountancy/customer/index.php');
$result = $db->query($sql);
if (! $result) {
if (!$result) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -172,12 +172,12 @@ if ($action == 'validatehistory') {
if ($objp->aarowid_suggest > 0)
{
$sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet";
$sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$resqlupdate = $db->query($sqlupdate);
if (! $resqlupdate)
if (!$resqlupdate)
{
$error++;
setEventMessages($db->lasterror(), null, 'errors');
@ -278,11 +278,11 @@ if ($resql) {
}
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i ++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -338,7 +338,7 @@ $resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ( $row = $db->fetch_row($resql)) {
while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind')
{
@ -355,11 +355,11 @@ if ($resql) {
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -413,11 +413,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
print '<tr><td>' . $row[0] . '</td>';
for($i = 1; $i <= 12; $i ++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right"><b>' . price($row[13]) . '</b></td>';
print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -465,11 +465,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
print '<tr><td>' . $row[0] . '</td>';
for($i = 1; $i <= 12; $i ++) {
print '<td class="nowrap right">' . price(price2num($row[$i])) . '</td>';
print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price(price2num($row[$i])).'</td>';
}
print '<td class="nowrap right"><b>' . price(price2num($row[13])) . '</b></td>';
print '<td class="nowrap right"><b>'.price(price2num($row[13])).'</b></td>';
print '</tr>';
}
$db->free($resql);

View File

@ -26,16 +26,16 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","compta","accountancy","productbatch"));
$langs->loadLangs(array("bills", "compta", "accountancy", "productbatch"));
$account_parent = GETPOST('account_parent');
$changeaccount = GETPOST('changeaccount');
@ -48,14 +48,14 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
$search_day=GETPOST("search_day", "int");
$search_month=GETPOST("search_month", "int");
$search_year=GETPOST("search_year", "int");
$search_day = GETPOST("search_day", "int");
$search_month = GETPOST("search_month", "int");
$search_year = GETPOST("search_year", "int");
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -63,9 +63,9 @@ if (empty($page) || $page < 0) $page = 0;
$pageprev = $page - 1;
$pagenext = $page + 1;
$offset = $limit * $page;
if (! $sortfield)
if (!$sortfield)
$sortfield = "f.datef, f.ref, fd.rowid";
if (! $sortorder) {
if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC";
}
@ -74,7 +74,7 @@ if (! $sortorder) {
// Security check
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$formaccounting = new FormAccounting($db);
@ -105,27 +105,27 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0;
if (! (GETPOST('account_parent', 'int') >= 0))
if (!(GETPOST('account_parent', 'int') >= 0))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
}
if (! $error)
if (!$error)
{
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l";
$sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l";
$sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN ('.implode(',', $changeaccount).')';
dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1);
dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
}
if (! $error) {
if (!$error) {
$db->commit();
setEventMessages($langs->trans('Save'), null, 'mesgs');
} else {
@ -133,7 +133,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
setEventMessages($db->lasterror(), null, 'errors');
}
$account_parent = ''; // Protection to avoid to mass apply it a second time
$account_parent = ''; // Protection to avoid to mass apply it a second time
}
}
@ -145,7 +145,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$form = new Form($db);
$formother = new FormOther($db);
llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched"));
llxHeader('', $langs->trans("CustomersVentilation").' - '.$langs->trans("Dispatched"));
print '<script type="text/javascript">
$(function () {
@ -168,28 +168,28 @@ print '<script type="text/javascript">
* Customer Invoice lines
*/
$sql = "SELECT f.rowid as facid, f.ref as ref, f.type, f.datef, f.ref_client,";
$sql.= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
$sql.= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number, aa.label as label_compte,";
$sql.= " fd.situation_percent,";
$sql.= " co.code as country_code, co.label as country,";
$sql.= " s.tva_intra";
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " WHERE fd.fk_code_ventilation > 0";
$sql.= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$sql.= " AND f.fk_statut > 0";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
$sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
$sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number, aa.label as label_compte,";
$sql .= " fd.situation_percent,";
$sql .= " co.code as country_code, co.label as country,";
$sql .= " s.tva_intra";
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " WHERE fd.fk_code_ventilation > 0";
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
} else {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_STANDARD.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
}
if ($search_lineid) {
$sql .= natural_search("fd.rowid", $search_lineid, 1);
@ -215,25 +215,25 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) {
$sql .= natural_search("fd.tva_tx", price2num($search_vat), 1);
}
$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value)
{
$country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search(array("co.code","co.label"), $search_country);
else $sql .= natural_search(array("co.code", "co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
}
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
@ -257,22 +257,22 @@ if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice);
if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref);
if ($search_label) $param .= "&search_label=" . urlencode($search_label);
if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc);
if ($search_account) $param .= "&search_account=" . urlencode($search_account);
if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_invoice) $param .= "&search_invoice=".urlencode($search_invoice);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc);
if ($search_account) $param .= "&search_account=".urlencode($search_account);
if ($search_vat) $param .= "&search_vat=".urlencode($search_vat);
if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year);
if ($search_country) $param .= "&search_country=" . urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra);
if ($search_country) $param .= "&search_country=".urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -282,40 +282,40 @@ if ($result) {
print '<input type="hidden" name="page" value="'.$page.'">';
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneCustomer") . '</span><br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneCustomer").'</span><br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print '<br><div class="inline-block divButAction">'.$langs->trans("ChangeAccount").'<br>';
print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '"/></div>';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre center nowraponall">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
}
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
print '<td class="liste_titre center">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print "</td></tr>\n";
@ -331,15 +331,15 @@ if ($result) {
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder, 'center ');
$clickpicto=$form->showCheckAddButtons();
$clickpicto = $form->showCheckAddButtons();
print_liste_field_titre($clickpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n";
$facture_static = new Facture($db);
$product_static = new Product($db);
while ( $objp = $db->fetch_object($result) ) {
$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label_compte;
while ($objp = $db->fetch_object($result)) {
$codecompta = length_accountg($objp->account_number).' - '.$objp->label_compte;
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
@ -353,13 +353,13 @@ if ($result) {
print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>';
print '<td>'.$objp->rowid.'</td>';
// Ref Invoice
print '<td class="nowraponall">' . $facture_static->getNomUrl(1) . '</td>';
print '<td class="nowraponall">'.$facture_static->getNomUrl(1).'</td>';
// Date invoice
print '<td class="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
// Ref Product
print '<td>';
@ -374,30 +374,30 @@ if ($result) {
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
print '</td>';
print '<td class="nowrap right">' . price($objp->total_ht) . '</td>';
print '<td class="nowrap right">'.price($objp->total_ht).'</td>';
print '<td class="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
// Country
print '<td>';
if ($objp->country_code)
{
print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')';
print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
}
print '</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td>'.$objp->tva_intra.'</td>';
print '<td class="center">';
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')).'">';
print $codecompta.' <a href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit();
print '</a>';
print '</td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
print "</tr>";
$i ++;
$i++;
}
print "</table>";

View File

@ -25,13 +25,13 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","main","accountancy"));
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
@ -39,16 +39,16 @@ if (empty($conf->accounting->enabled)) {
}
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else
{
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
@ -75,19 +75,19 @@ if ($action == 'clean' || $action == 'validatehistory')
{
// Clean database
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as fd";
$sql1 .= " SET fk_code_ventilation = 0";
$sql1 .= ' WHERE fd.fk_code_ventilation NOT IN';
$sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
$sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture_fourn WHERE entity = '.$conf->entity.')';
$sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt';
$sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst';
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE entity = '.$conf->entity.')';
$sql1 .= ' AND fk_code_ventilation <> 0';
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -118,24 +118,24 @@ if ($action == 'validatehistory') {
// Supplier Invoice Lines (must be same request than into page list.php for manual binding)
$sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
$sql.= " aa.rowid as aarowid,";
$sql.= " co.code as country_code, co.label as country_label,";
$sql.= " s.tva_intra";
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity;
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql.= " AND l.product_type <= 2";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
$sql .= " aa.rowid as aarowid,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2";
dol_syslog('htdocs/accountancy/supplier/index.php');
$result = $db->query($sql);
if (! $result) {
if (!$result) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
} else {
@ -171,12 +171,12 @@ if ($action == 'validatehistory') {
if ($objp->aarowid_suggest > 0)
{
$sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
$sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$resqlupdate = $db->query($sqlupdate);
if (! $resqlupdate)
if (!$resqlupdate)
{
$error++;
setEventMessages($db->lasterror(), null, 'errors');
@ -205,18 +205,18 @@ if ($action == 'validatehistory') {
llxHeader('', $langs->trans("SuppliersVentilation"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy');
print load_fiche_titre($langs->trans("SuppliersVentilation")." ".$textprevyear."&nbsp;".$langs->trans("Year")."&nbsp;".$year_start."&nbsp;".$textnextyear, '', 'title_accountancy');
print '<span class="opacitymedium">'.$langs->trans("DescVentilSupplier") . '<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilSupplier").'<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
print '</span><br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
$buttonbind = '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?year='.$year_current.'&action=validatehistory">'.$langs->trans("ValidateHistory").'</a>';
print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
@ -256,7 +256,7 @@ $resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ( $row = $db->fetch_row($resql)) {
while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind')
{
@ -271,11 +271,11 @@ if ($resql) {
}
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i ++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -326,7 +326,7 @@ $resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ( $row = $db->fetch_row($resql)) {
while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind')
{
@ -341,11 +341,11 @@ if ($resql) {
}
else print $row[1];
print '</td>';
for($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right">' . price($row[13]) . '</td>';
print '<td class="nowrap right"><b>' . price($row[14]) . '</b></td>';
print '<td class="nowrap right">'.price($row[13]).'</td>';
print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
print '</tr>';
}
$db->free($resql);
@ -395,11 +395,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
print '<tr><td>' . $row[0] . '</td>';
for($i = 1; $i <= 12; $i ++) {
print '<td class="nowrap right">' . price($row[$i]) . '</td>';
print '<tr><td>'.$row[0].'</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>';
}
print '<td class="nowrap right"><b>' . price($row[13]) . '</b></td>';
print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
print '</tr>';
}
$db->free($resql);

View File

@ -26,18 +26,18 @@
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","accountancy","productbatch"));
$langs->loadLangs(array("compta", "bills", "other", "accountancy", "productbatch"));
$account_parent = GETPOST('account_parent');
$changeaccount = GETPOST('changeaccount');
@ -50,14 +50,14 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
$search_day=GETPOST("search_day", "int");
$search_month=GETPOST("search_month", "int");
$search_year=GETPOST("search_year", "int");
$search_day = GETPOST("search_day", "int");
$search_month = GETPOST("search_month", "int");
$search_year = GETPOST("search_year", "int");
$search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -65,9 +65,9 @@ if (empty($page) || $page < 0) $page = 0;
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield)
if (!$sortfield)
$sortfield = "f.datef, f.ref, l.rowid";
if (! $sortorder) {
if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC";
}
@ -76,7 +76,7 @@ if (! $sortorder) {
// Security check
if ($user->socid > 0)
accessforbidden();
if (! $user->rights->accounting->bind->write)
if (!$user->rights->accounting->bind->write)
accessforbidden();
$formaccounting = new FormAccounting($db);
@ -107,28 +107,28 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0;
if (! (GETPOST('account_parent', 'int') >= 0))
if (!(GETPOST('account_parent', 'int') >= 0))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
}
if (! $error)
if (!$error)
{
$db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')';
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as l";
$sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
$sql1 .= ' WHERE l.rowid IN ('.implode(',', $changeaccount).')';
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1);
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
$resql1 = $db->query($sql1);
if (! $resql1) {
$error ++;
if (!$resql1) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
}
if (! $error) {
if (!$error) {
$db->commit();
setEventMessages($langs->trans('Save'), null, 'mesgs');
} else {
@ -136,7 +136,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
setEventMessages($db->lasterror(), null, 'errors');
}
$account_parent = ''; // Protection to avoid to mass apply it a second time
$account_parent = ''; // Protection to avoid to mass apply it a second time
}
}
@ -148,7 +148,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) {
$form = new Form($db);
$formother = new FormOther($db);
llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched"));
llxHeader('', $langs->trans("SuppliersVentilation").' - '.$langs->trans("Dispatched"));
print '<script type="text/javascript">
$(function () {
@ -171,21 +171,21 @@ print '<script type="text/javascript">
* Supplier Invoice lines
*/
$sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
$sql.= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
$sql.= " aa.label, aa.account_number, ";
$sql.= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,";
$sql.= " co.code as country_code, co.label as country,";
$sql.= " s.tva_intra";
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
$sql.= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
$sql .= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
$sql .= " aa.label, aa.account_number, ";
$sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,";
$sql .= " co.code as country_code, co.label as country,";
$sql .= " s.tva_intra";
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1);
}
@ -210,30 +210,30 @@ if (strlen(trim($search_account))) {
if (strlen(trim($search_vat))) {
$sql .= natural_search("l.tva_tx", price2num($search_vat), 1);
}
$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value)
{
$country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search(array("co.code","co.label"), $search_country);
else $sql .= natural_search(array("co.code", "co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
}
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
// Add where from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= $db->order($sortfield, $sortorder);
@ -259,22 +259,22 @@ if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice);
if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref);
if ($search_label) $param .= "&search_label=" . urlencode($search_label);
if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc);
if ($search_account) $param .= "&search_account=" . urlencode($search_account);
if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_invoice) $param .= "&search_invoice=".urlencode($search_invoice);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc);
if ($search_account) $param .= "&search_account=".urlencode($search_account);
if ($search_vat) $param .= "&search_vat=".urlencode($search_vat);
if ($search_day) $param .= '&search_day='.urlencode($search_day);
if ($search_month) $param .= '&search_month='.urlencode($search_month);
if ($search_year) $param .= '&search_year='.urlencode($search_year);
if ($search_country) $param .= "&search_country=" . urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra);
if ($search_country) $param .= "&search_country=".urlencode($search_country);
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -285,39 +285,39 @@ if ($result) {
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneSupplier") . '</span><br>';
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneSupplier").'</span><br>';
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print '<br><div class="inline-block divButAction">'.$langs->trans("ChangeAccount").'<br>';
print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("ChangeBinding").'" /></div>';
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// We add search filter
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'""></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre center nowraponall">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
print '<td class="liste_titre">';
print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
// print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="' . dol_escape_htmltag($search_tvaintra) . '"></td>';
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
print '<td class="liste_titre center">';
$searchpicto=$form->showFilterButtons();
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print "</tr>\n";
@ -335,7 +335,7 @@ if ($result) {
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder, 'center ');
$checkpicto=$form->showCheckAddButtons();
$checkpicto = $form->showCheckAddButtons();
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n";
@ -345,7 +345,7 @@ if ($result) {
while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result);
$codecompta = length_accountg($objp->account_number) . ' - ' . $objp->label;
$codecompta = length_accountg($objp->account_number).' - '.$objp->label;
$facturefournisseur_static->ref = $objp->ref;
$facturefournisseur_static->id = $objp->facid;
@ -358,17 +358,17 @@ if ($result) {
print '<tr class="oddeven">';
// Line id
print '<td>' . $objp->rowid . '</td>';
print '<td>'.$objp->rowid.'</td>';
// Ref Invoice
print '<td class="nowraponall">' . $facturefournisseur_static->getNomUrl(1) . '</td>';
print '<td class="nowraponall">'.$facturefournisseur_static->getNomUrl(1).'</td>';
print '<td class="tdoverflowonsmartphone">';
print $objp->invoice_label;
print '</td>';
// Date invoice
print '<td class="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
// Ref product
print '<td>';
@ -384,27 +384,27 @@ if ($result) {
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
print '</td>';
print '<td class="nowrap right">' . price($objp->total_ht) . '</td>';
print '<td class="nowrap right">'.price($objp->total_ht).'</td>';
print '<td class="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
print '<td>';
if ($objp->country_code)
{
print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')';
print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
}
print '</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td>'.$objp->tva_intra.'</td>';
print '<td class="center">';
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')) . '">';
print $codecompta.' <a href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit();
print '</a></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
print '</tr>';
$i ++;
$i++;
}
print '</table>';
print "</div>";

View File

@ -129,22 +129,22 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT id, code, type, libelle as label, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t";
$sql.= " WHERE t.entity IN (".getEntity('c_paiement').")";
$sql.= " AND t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_paiement as t";
$sql .= " WHERE t.entity IN (".getEntity('c_paiement').")";
$sql .= " AND t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -198,19 +198,19 @@ class Setup extends DolibarrApi
// Note: The filter is not applied in the SQL request because it must
// be applied to the translated names, not to the names in database.
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
$sql.=" WHERE 1 = 1";
$sql .= " WHERE 1 = 1";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -347,21 +347,21 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid, code, label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_availability as t";
$sql.= " WHERE t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t";
$sql .= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -515,23 +515,23 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT id, code, type, libelle as label, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
$sql.= " WHERE t.active = ".$active;
if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
$sql .= " WHERE t.active = ".$active;
if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -579,23 +579,23 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid, code, element as type, libelle as label, source, module, position";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as t";
$sql.= " WHERE t.active = ".$active;
if ($type) $sql.=" AND type LIKE '%" . $this->db->escape($type) . "%'";
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as t";
$sql .= " WHERE t.active = ".$active;
if ($type) $sql .= " AND type LIKE '%".$this->db->escape($type)."%'";
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -642,22 +642,22 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid, code, label, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_civility as t";
$sql.= " WHERE t.active = ".$active;
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
$sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t";
$sql .= " WHERE t.active = ".$active;
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -703,33 +703,33 @@ class Setup extends DolibarrApi
{
$list = array();
$sql = "SELECT t.code_iso, t.label, t.unicode";
if (!empty($multicurrency)) $sql.= " , cr.date_sync, cr.rate ";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies as t";
if (!empty($multicurrency)) $sql .= " , cr.date_sync, cr.rate ";
$sql .= " FROM ".MAIN_DB_PREFIX."c_currencies as t";
if (!empty($multicurrency)) {
$sql.= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso";
$sql.= " JOIN ".MAIN_DB_PREFIX."multicurrency_rate as cr ON (m.rowid = cr.fk_multicurrency)";
$sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso";
$sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency_rate as cr ON (m.rowid = cr.fk_multicurrency)";
}
$sql.= " WHERE t.active = ".$active;
$sql .= " WHERE t.active = ".$active;
if (!empty($multicurrency)) {
$sql.= " AND m.entity IN (".getEntity('multicurrency').")";
$sql .= " AND m.entity IN (".getEntity('multicurrency').")";
if (!empty($multicurrency) && $multicurrency != 2) {
$sql.= " AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX."multicurrency_rate AS cr2 WHERE cr2.fk_multicurrency = m.rowid)";
$sql .= " AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX."multicurrency_rate AS cr2 WHERE cr2.fk_multicurrency = m.rowid)";
}
}
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -772,27 +772,27 @@ class Setup extends DolibarrApi
{
$list = array();
if ($type == 'thirdparty') $type='societe';
if ($type == 'contact') $type='socpeople';
if ($type == 'thirdparty') $type = 'societe';
if ($type == 'contact') $type = 'socpeople';
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t";
$sql.= " WHERE t.entity IN (".getEntity('extrafields').")";
if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'";
$sql .= " FROM ".MAIN_DB_PREFIX."extrafields as t";
$sql .= " WHERE t.entity IN (".getEntity('extrafields').")";
if (!empty($type)) $sql .= " AND t.elementtype = '".$this->db->escape($type)."'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
@ -800,19 +800,19 @@ class Setup extends DolibarrApi
while ($tab = $this->db->fetch_object($resql))
{
// New usage
$list[$tab->elementtype][$tab->name]['type']=$tab->type;
$list[$tab->elementtype][$tab->name]['label']=$tab->label;
$list[$tab->elementtype][$tab->name]['size']=$tab->size;
$list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype;
$list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault;
$list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed;
$list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique;
$list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired;
$list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : '');
$list[$tab->elementtype][$tab->name]['pos']=$tab->pos;
$list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable;
$list[$tab->elementtype][$tab->name]['perms']=$tab->perms;
$list[$tab->elementtype][$tab->name]['list']=$tab->list;
$list[$tab->elementtype][$tab->name]['type'] = $tab->type;
$list[$tab->elementtype][$tab->name]['label'] = $tab->label;
$list[$tab->elementtype][$tab->name]['size'] = $tab->size;
$list[$tab->elementtype][$tab->name]['elementtype'] = $tab->elementtype;
$list[$tab->elementtype][$tab->name]['default'] = $tab->fielddefault;
$list[$tab->elementtype][$tab->name]['computed'] = $tab->fieldcomputed;
$list[$tab->elementtype][$tab->name]['unique'] = $tab->fieldunique;
$list[$tab->elementtype][$tab->name]['required'] = $tab->fieldrequired;
$list[$tab->elementtype][$tab->name]['param'] = ($tab->param ? unserialize($tab->param) : '');
$list[$tab->elementtype][$tab->name]['pos'] = $tab->pos;
$list[$tab->elementtype][$tab->name]['alwayseditable'] = $tab->alwayseditable;
$list[$tab->elementtype][$tab->name]['perms'] = $tab->perms;
$list[$tab->elementtype][$tab->name]['list'] = $tab->list;
}
}
}
@ -821,7 +821,7 @@ class Setup extends DolibarrApi
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
}
if (! count($list))
if (!count($list))
{
throw new RestException(404, 'No extrafield found');
}
@ -852,23 +852,23 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
$sql.= " AND t.active = ".$active;
if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'";
if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'";
$sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
$sql .= " AND t.active = ".$active;
if ($zipcode) $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'";
if ($town) $sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -916,22 +916,22 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
$sql.= " WHERE t.entity IN (".getEntity('c_payment_term').")";
$sql.= " AND t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
$sql .= " WHERE t.entity IN (".getEntity('c_payment_term').")";
$sql .= " AND t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -977,18 +977,18 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid as id, code, libelle as label, description, tracking, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
$sql.= " WHERE t.entity IN (".getEntity('c_shipment_mode').")";
$sql.= " AND t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
$sql .= " WHERE t.entity IN (".getEntity('c_shipment_mode').")";
$sql .= " AND t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
@ -1038,21 +1038,21 @@ class Setup extends DolibarrApi
$list = array();
//TODO link with multicurrency module
$sql = "SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_units as t";
$sql.= " WHERE t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_units as t";
$sql .= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -1165,21 +1165,21 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid, code, pos, label, use_default, description";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t";
$sql.= " WHERE t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t";
$sql .= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -1225,21 +1225,21 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid, code, pos, label, use_default, color, description";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t";
$sql.= " WHERE t.active = ".$active;
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t";
$sql .= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -1285,23 +1285,23 @@ class Setup extends DolibarrApi
$list = array();
$sql = "SELECT rowid, code, pos, label, use_default, description";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t";
$sql.= " WHERE t.active = ".$active;
if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t";
$sql .= " WHERE t.active = ".$active;
if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $this->db->order($sortfield, $sortorder);
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
@ -1342,7 +1342,7 @@ class Setup extends DolibarrApi
{
global $langs, $conf;
if (! DolibarrApiAccess::$user->admin
if (!DolibarrApiAccess::$user->admin
&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK))
{
throw new RestException(503, 'Error API open to admin users only or to login user defined with constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK');
@ -1360,13 +1360,13 @@ class Setup extends DolibarrApi
$file_list = array('missing' => array(), 'updated' => array());
// Local file to compare to
$xmlshortfile = GETPOST('xmlshortfile')?GETPOST('xmlshortfile'):'/install/filelist-'.DOL_VERSION.'.xml';
$xmlshortfile = GETPOST('xmlshortfile') ?GETPOST('xmlshortfile') : '/install/filelist-'.DOL_VERSION.'.xml';
$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
// Remote file to compare to
$xmlremote = ($target == 'default' ? '' : $target);
if (empty($xmlremote) && ! empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL;
$param='MAIN_FILECHECK_URL_'.DOL_VERSION;
if (empty($xmlremote) && ! empty($conf->global->$param)) $xmlremote = $conf->global->$param;
if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL;
$param = 'MAIN_FILECHECK_URL_'.DOL_VERSION;
if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param;
if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
if ($target == 'local')
@ -1377,7 +1377,7 @@ class Setup extends DolibarrApi
}
else
{
throw new RestException(500, $langs->trans('XmlNotFound') . ': ' . $xmlfile);
throw new RestException(500, $langs->trans('XmlNotFound').': '.$xmlfile);
}
}
else
@ -1385,7 +1385,7 @@ class Setup extends DolibarrApi
$xmlarray = getURLContent($xmlremote);
// Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404')
if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404')
{
$xmlfile = $xmlarray['content'];
//print "xmlfilestart".$xmlfile."endxmlfile";
@ -1393,7 +1393,7 @@ class Setup extends DolibarrApi
}
else
{
$errormsg=$langs->trans('XmlNotFound') . ': ' . $xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg'];
$errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg'];
throw new RestException(500, $errormsg);
}
}
@ -1409,83 +1409,83 @@ class Setup extends DolibarrApi
// Forced constants
if (is_object($xml->dolibarr_constants[0]))
{
$out.=load_fiche_titre($langs->trans("ForcedConstants"));
$out .= load_fiche_titre($langs->trans("ForcedConstants"));
$out.='<div class="div-table-responsive-no-min">';
$out.='<table class="noborder">';
$out.='<tr class="liste_titre">';
$out.='<td>#</td>';
$out.='<td>' . $langs->trans("Constant") . '</td>';
$out.='<td align="center">' . $langs->trans("ExpectedValue") . '</td>';
$out.='<td align="center">' . $langs->trans("Value") . '</td>';
$out.='</tr>'."\n";
$out .= '<div class="div-table-responsive-no-min">';
$out .= '<table class="noborder">';
$out .= '<tr class="liste_titre">';
$out .= '<td>#</td>';
$out .= '<td>'.$langs->trans("Constant").'</td>';
$out .= '<td align="center">'.$langs->trans("ExpectedValue").'</td>';
$out .= '<td align="center">'.$langs->trans("Value").'</td>';
$out .= '</tr>'."\n";
$i = 0;
foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement
{
$constname=$constant['name'];
$constvalue=(string) $constant;
$constvalue = (empty($constvalue)?'0':$constvalue);
$constname = $constant['name'];
$constvalue = (string) $constant;
$constvalue = (empty($constvalue) ? '0' : $constvalue);
// Value found
$value='';
if ($constname && $conf->global->$constname != '') $value=$conf->global->$constname;
$valueforchecksum=(empty($value)?'0':$value);
$value = '';
if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname;
$valueforchecksum = (empty($value) ? '0' : $value);
$checksumconcat[]=$valueforchecksum;
$checksumconcat[] = $valueforchecksum;
$i++;
$out.='<tr class="oddeven">';
$out.='<td>'.$i.'</td>' . "\n";
$out.='<td>'.$constname.'</td>' . "\n";
$out.='<td align="center">'.$constvalue.'</td>' . "\n";
$out.='<td align="center">'.$valueforchecksum.'</td>' . "\n";
$out.="</tr>\n";
$out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n";
$out .= '<td>'.$constname.'</td>'."\n";
$out .= '<td align="center">'.$constvalue.'</td>'."\n";
$out .= '<td align="center">'.$valueforchecksum.'</td>'."\n";
$out .= "</tr>\n";
}
if ($i==0)
if ($i == 0)
{
$out.='<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
$out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$out.='</table>';
$out.='</div>';
$out .= '</table>';
$out .= '</div>';
$out.='<br>';
$out .= '<br>';
}
// Scan htdocs
if (is_object($xml->dolibarr_htdocs_dir[0]))
{
//var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit;
$includecustom=(empty($xml->dolibarr_htdocs_dir[0]['includecustom'])?0:$xml->dolibarr_htdocs_dir[0]['includecustom']);
$includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']);
// Defined qualified files (must be same than into generate_filelist_xml.php)
$regextoinclude='\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$';
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$regextoinclude = '\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$';
$regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude);
// Fill file_list with files in signature, new files, modified files
$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list
$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list
// Complete with list of new files
foreach ($scanfiles as $keyfile => $valfile)
{
$tmprelativefilename=preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']);
if (! in_array($tmprelativefilename, $file_list['insignature']))
$tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']);
if (!in_array($tmprelativefilename, $file_list['insignature']))
{
$md5newfile=@md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file
$file_list['added'][]=array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile);
$md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file
$file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile);
}
}
// Files missings
$out.=load_fiche_titre($langs->trans("FilesMissing"));
$out .= load_fiche_titre($langs->trans("FilesMissing"));
$out.='<div class="div-table-responsive-no-min">';
$out.='<table class="noborder">';
$out.='<tr class="liste_titre">';
$out.='<td>#</td>';
$out.='<td>' . $langs->trans("Filename") . '</td>';
$out.='<td align="center">' . $langs->trans("ExpectedChecksum") . '</td>';
$out.='</tr>'."\n";
$out .= '<div class="div-table-responsive-no-min">';
$out .= '<table class="noborder">';
$out .= '<tr class="liste_titre">';
$out .= '<td>#</td>';
$out .= '<td>'.$langs->trans("Filename").'</td>';
$out .= '<td align="center">'.$langs->trans("ExpectedChecksum").'</td>';
$out .= '</tr>'."\n";
$tmpfilelist = dol_sort_array($file_list['missing'], 'filename');
if (is_array($tmpfilelist) && count($tmpfilelist))
{
@ -1493,36 +1493,36 @@ class Setup extends DolibarrApi
foreach ($tmpfilelist as $file)
{
$i++;
$out.='<tr class="oddeven">';
$out.='<td>'.$i.'</td>' . "\n";
$out.='<td>'.$file['filename'].'</td>' . "\n";
$out.='<td align="center">'.$file['expectedmd5'].'</td>' . "\n";
$out.="</tr>\n";
$out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n";
$out .= '<td>'.$file['filename'].'</td>'."\n";
$out .= '<td align="center">'.$file['expectedmd5'].'</td>'."\n";
$out .= "</tr>\n";
}
}
else
{
$out.='<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
$out .= '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$out.='</table>';
$out.='</div>';
$out .= '</table>';
$out .= '</div>';
$out.='<br>';
$out .= '<br>';
// Files modified
$out.=load_fiche_titre($langs->trans("FilesModified"));
$out .= load_fiche_titre($langs->trans("FilesModified"));
$totalsize=0;
$out.='<div class="div-table-responsive-no-min">';
$out.='<table class="noborder">';
$out.='<tr class="liste_titre">';
$out.='<td>#</td>';
$out.='<td>' . $langs->trans("Filename") . '</td>';
$out.='<td align="center">' . $langs->trans("ExpectedChecksum") . '</td>';
$out.='<td align="center">' . $langs->trans("CurrentChecksum") . '</td>';
$out.='<td class="right">' . $langs->trans("Size") . '</td>';
$out.='<td class="right">' . $langs->trans("DateModification") . '</td>';
$out.='</tr>'."\n";
$totalsize = 0;
$out .= '<div class="div-table-responsive-no-min">';
$out .= '<table class="noborder">';
$out .= '<tr class="liste_titre">';
$out .= '<td>#</td>';
$out .= '<td>'.$langs->trans("Filename").'</td>';
$out .= '<td align="center">'.$langs->trans("ExpectedChecksum").'</td>';
$out .= '<td align="center">'.$langs->trans("CurrentChecksum").'</td>';
$out .= '<td class="right">'.$langs->trans("Size").'</td>';
$out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
$out .= '</tr>'."\n";
$tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename');
if (is_array($tmpfilelist2) && count($tmpfilelist2))
{
@ -1530,49 +1530,49 @@ class Setup extends DolibarrApi
foreach ($tmpfilelist2 as $file)
{
$i++;
$out.='<tr class="oddeven">';
$out.='<td>'.$i.'</td>' . "\n";
$out.='<td>'.$file['filename'].'</td>' . "\n";
$out.='<td align="center">'.$file['expectedmd5'].'</td>' . "\n";
$out.='<td align="center">'.$file['md5'].'</td>' . "\n";
$out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n";
$out .= '<td>'.$file['filename'].'</td>'."\n";
$out .= '<td align="center">'.$file['expectedmd5'].'</td>'."\n";
$out .= '<td align="center">'.$file['md5'].'</td>'."\n";
$size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']);
$totalsize += $size;
$out.='<td class="right">'.dol_print_size($size).'</td>' . "\n";
$out.='<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>' . "\n";
$out.="</tr>\n";
$out .= '<td class="right">'.dol_print_size($size).'</td>'."\n";
$out .= '<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>'."\n";
$out .= "</tr>\n";
}
$out.='<tr class="liste_total">';
$out.='<td></td>' . "\n";
$out.='<td>'.$langs->trans("Total").'</td>' . "\n";
$out.='<td align="center"></td>' . "\n";
$out.='<td align="center"></td>' . "\n";
$out.='<td class="right">'.dol_print_size($totalsize).'</td>' . "\n";
$out.='<td class="right"></td>' . "\n";
$out.="</tr>\n";
$out .= '<tr class="liste_total">';
$out .= '<td></td>'."\n";
$out .= '<td>'.$langs->trans("Total").'</td>'."\n";
$out .= '<td align="center"></td>'."\n";
$out .= '<td align="center"></td>'."\n";
$out .= '<td class="right">'.dol_print_size($totalsize).'</td>'."\n";
$out .= '<td class="right"></td>'."\n";
$out .= "</tr>\n";
}
else
{
$out.='<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
$out .= '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$out.='</table>';
$out.='</div>';
$out .= '</table>';
$out .= '</div>';
$out.='<br>';
$out .= '<br>';
// Files added
$out.=load_fiche_titre($langs->trans("FilesAdded"));
$out .= load_fiche_titre($langs->trans("FilesAdded"));
$totalsize = 0;
$out.='<div class="div-table-responsive-no-min">';
$out.='<table class="noborder">';
$out.='<tr class="liste_titre">';
$out.='<td>#</td>';
$out.='<td>' . $langs->trans("Filename") . '</td>';
$out.='<td align="center">' . $langs->trans("ExpectedChecksum") . '</td>';
$out.='<td align="center">' . $langs->trans("CurrentChecksum") . '</td>';
$out.='<td class="right">' . $langs->trans("Size") . '</td>';
$out.='<td class="right">' . $langs->trans("DateModification") . '</td>';
$out.='</tr>'."\n";
$out .= '<div class="div-table-responsive-no-min">';
$out .= '<table class="noborder">';
$out .= '<tr class="liste_titre">';
$out .= '<td>#</td>';
$out .= '<td>'.$langs->trans("Filename").'</td>';
$out .= '<td align="center">'.$langs->trans("ExpectedChecksum").'</td>';
$out .= '<td align="center">'.$langs->trans("CurrentChecksum").'</td>';
$out .= '<td class="right">'.$langs->trans("Size").'</td>';
$out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
$out .= '</tr>'."\n";
$tmpfilelist3 = dol_sort_array($file_list['added'], 'filename');
if (is_array($tmpfilelist3) && count($tmpfilelist3))
{
@ -1580,32 +1580,32 @@ class Setup extends DolibarrApi
foreach ($tmpfilelist3 as $file)
{
$i++;
$out.='<tr class="oddeven">';
$out.='<td>'.$i.'</td>' . "\n";
$out.='<td>'.$file['filename'].'</td>' . "\n";
$out.='<td align="center">'.$file['expectedmd5'].'</td>' . "\n";
$out.='<td align="center">'.$file['md5'].'</td>' . "\n";
$out .= '<tr class="oddeven">';
$out .= '<td>'.$i.'</td>'."\n";
$out .= '<td>'.$file['filename'].'</td>'."\n";
$out .= '<td align="center">'.$file['expectedmd5'].'</td>'."\n";
$out .= '<td align="center">'.$file['md5'].'</td>'."\n";
$size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']);
$totalsize += $size;
$out.='<td class="right">'.dol_print_size($size).'</td>' . "\n";
$out.='<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>' . "\n";
$out.="</tr>\n";
$out .= '<td class="right">'.dol_print_size($size).'</td>'."\n";
$out .= '<td class="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>'."\n";
$out .= "</tr>\n";
}
$out.='<tr class="liste_total">';
$out.='<td></td>' . "\n";
$out.='<td>'.$langs->trans("Total").'</td>' . "\n";
$out.='<td align="center"></td>' . "\n";
$out.='<td align="center"></td>' . "\n";
$out.='<td class="right">'.dol_print_size($totalsize).'</td>' . "\n";
$out.='<td class="right"></td>' . "\n";
$out.="</tr>\n";
$out .= '<tr class="liste_total">';
$out .= '<td></td>'."\n";
$out .= '<td>'.$langs->trans("Total").'</td>'."\n";
$out .= '<td align="center"></td>'."\n";
$out .= '<td align="center"></td>'."\n";
$out .= '<td class="right">'.dol_print_size($totalsize).'</td>'."\n";
$out .= '<td class="right"></td>'."\n";
$out .= "</tr>\n";
}
else
{
$out.='<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
$out .= '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$out.='</table>';
$out.='</div>';
$out .= '</table>';
$out .= '</div>';
// Show warning
@ -1638,24 +1638,24 @@ class Setup extends DolibarrApi
if (count($file_list['added']))
{
$resultcode = 'warning';
$resultcomment='FileIntegrityIsOkButFilesWereAdded';
$resultcomment = 'FileIntegrityIsOkButFilesWereAdded';
//$outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>';
$outcurrentchecksum = $checksumget;
$outcurrentchecksum = $checksumget;
}
else
{
$resultcode = 'ok';
$resultcomment='Success';
$resultcomment = 'Success';
//$outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>';
$outcurrentchecksum = $checksumget;
$outcurrentchecksum = $checksumget;
}
}
else
{
$resultcode = 'error';
$resultcomment='Error';
$resultcomment = 'Error';
//$outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>';
$outcurrentchecksum = $checksumget;
$outcurrentchecksum = $checksumget;
}
}
else {

View File

@ -35,7 +35,7 @@
*/
// Protection to avoid direct call of template
if (empty($object) || ! is_object($object))
if (empty($object) || !is_object($object))
{
print "Error, template page can't be called as URL";
exit;
@ -44,11 +44,11 @@ if (empty($object) || ! is_object($object))
global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax;
if (empty($dateSelector)) $dateSelector=0;
if (empty($forceall)) $forceall=0;
if (empty($senderissupplier)) $senderissupplier=0;
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0;
if (empty($dateSelector)) $dateSelector = 0;
if (empty($forceall)) $forceall = 0;
if (empty($senderissupplier)) $senderissupplier = 0;
if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0;
if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax = 0;
// add html5 elements
$domData = ' data-element="'.$line->element.'"';
@ -59,11 +59,11 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
// Lines for extrafield
$objectline = new BOMLine($object->db);
$coldisplay=0;
$coldisplay = 0;
print "<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->\n";
print '<tr id="row-'.$line->id.'" class="drag drop oddeven" '.$domData.' >';
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td class="linecolnum center">'.($i+1).'</td>';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td class="linecolnum center">'.($i + 1).'</td>';
$coldisplay++;
}
print '<td class="linecoldescription minwidth300imp">';
@ -75,10 +75,10 @@ print $tmpproduct->getNomUrl(1);
print '</td>';
print '<td class="linecolqty nowrap right">';
$coldisplay++;
echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price
echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price
print '</td>';
if($conf->global->PRODUCT_USE_UNITS)
if ($conf->global->PRODUCT_USE_UNITS)
{
print '<td class="linecoluseunit nowrap left">';
$label = $line->getLabelOfUnit('short');
@ -113,9 +113,9 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' )
print '<td class="linecoldelete center">';
$coldisplay++;
if (($line->fk_prev_id == null ) && empty($disableremove)) {
if (($line->fk_prev_id == null) && empty($disableremove)) {
//La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&amp;action=deleteline&amp;lineid=' . $line->id . '">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=deleteline&amp;lineid='.$line->id.'">';
print img_delete();
print '</a>';
}
@ -129,24 +129,24 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' )
echo img_up('default', 0, 'imgupforline');
print '</a>';
}
if ($i < $num-1) {
if ($i < $num - 1) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id.'">';
echo img_down('default', 0, 'imgdownforline');
print '</a>';
}
print '</td>';
} else {
print '<td '.(($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"').'></td>';
print '<td '.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'></td>';
$coldisplay++;
}
} else {
print '<td colspan="3"></td>';
$coldisplay=$coldisplay+3;
$coldisplay = $coldisplay + 3;
}
if ($action == 'selectlines') {
print '<td class="linecolcheck center">';
print '<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i+1).']" value="'.$line->id.'" >';
print '<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i + 1).']" value="'.$line->id.'" >';
print '</td>';
}
@ -155,7 +155,7 @@ print '</tr>';
//Line extrafield
if (!empty($extrafields))
{
print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"','colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1);
}
print "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";

View File

@ -40,15 +40,15 @@ class Ccountry // extends CommonObject
/**
* @var string Error code (or message)
*/
public $error='';
public $error = '';
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
public $element='ccountry'; //!< Id that identify managed objects
public $table_element='c_country'; //!< Name of table without prefix where object is stored
public $element = 'ccountry'; //!< Id that identify managed objects
public $table_element = 'c_country'; //!< Name of table without prefix where object is stored
/**
* @var int ID
@ -65,7 +65,7 @@ class Ccountry // extends CommonObject
public $active;
public $fields=array(
public $fields = array(
'label' => array('type'=>'varchar(250)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>15, 'notnull'=>-1, 'showoncombobox'=>'1')
);
@ -91,43 +91,43 @@ class Ccountry // extends CommonObject
public function create($user, $notrigger = 0)
{
global $conf, $langs;
$error=0;
$error = 0;
// Clean parameters
if (isset($this->code)) $this->code=trim($this->code);
if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso);
if (isset($this->label)) $this->label=trim($this->label);
if (isset($this->active)) $this->active=trim($this->active);
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->code_iso)) $this->code_iso = trim($this->code_iso);
if (isset($this->label)) $this->label = trim($this->label);
if (isset($this->active)) $this->active = trim($this->active);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_country(";
$sql.= "rowid,";
$sql.= "code,";
$sql.= "code_iso,";
$sql.= "label,";
$sql.= "active";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").",";
$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
$sql.= " ".(! isset($this->code_iso)?'NULL':"'".$this->db->escape($this->code_iso)."'").",";
$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
$sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'")."";
$sql.= ")";
$sql .= "rowid,";
$sql .= "code,";
$sql .= "code_iso,";
$sql .= "label,";
$sql .= "active";
$sql .= ") VALUES (";
$sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").",";
$sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").",";
$sql .= " ".(!isset($this->code_iso) ? 'NULL' : "'".$this->db->escape($this->code_iso)."'").",";
$sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").",";
$sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'")."";
$sql .= ")";
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (! $error)
if (!$error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country");
if (! $notrigger)
if (!$notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
@ -144,13 +144,13 @@ class Ccountry // extends CommonObject
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1*$error;
return -1 * $error;
}
else
{
@ -205,7 +205,7 @@ class Ccountry // extends CommonObject
}
else
{
$this->error="Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
@ -221,13 +221,13 @@ class Ccountry // extends CommonObject
public function update($user = null, $notrigger = 0)
{
global $conf, $langs;
$error=0;
$error = 0;
// Clean parameters
if (isset($this->code)) $this->code=trim($this->code);
if (isset($this->code_iso)) $this->code_iso=trim($this->code_iso);
if (isset($this->label)) $this->label=trim($this->label);
if (isset($this->active)) $this->active=trim($this->active);
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->code_iso)) $this->code_iso = trim($this->code_iso);
if (isset($this->label)) $this->label = trim($this->label);
if (isset($this->active)) $this->active = trim($this->active);
// Check parameters
@ -235,21 +235,21 @@ class Ccountry // extends CommonObject
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET";
$sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").",";
$sql.= " code_iso=".(isset($this->code_iso)?"'".$this->db->escape($this->code_iso)."'":"null").",";
$sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " active=".(isset($this->active)?$this->active:"null")."";
$sql.= " WHERE rowid=".$this->id;
$sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").",";
$sql .= " code_iso=".(isset($this->code_iso) ? "'".$this->db->escape($this->code_iso)."'" : "null").",";
$sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
$sql .= " active=".(isset($this->active) ? $this->active : "null")."";
$sql .= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (! $error)
if (!$error)
{
if (! $notrigger)
if (!$notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
@ -266,13 +266,13 @@ class Ccountry // extends CommonObject
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1*$error;
return -1 * $error;
}
else
{
@ -292,20 +292,20 @@ class Ccountry // extends CommonObject
public function delete($user, $notrigger = 0)
{
global $conf, $langs;
$error=0;
$error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_country";
$sql.= " WHERE rowid=".$this->id;
$sql .= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (! $error)
if (!$error)
{
if (! $notrigger)
if (!$notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
@ -322,13 +322,13 @@ class Ccountry // extends CommonObject
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1*$error;
return -1 * $error;
}
else
{

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@ class CUnits // extends CommonObject
/**
* @var string Error code (or message)
*/
public $error='';
public $error = '';
/**
* @var string[] Error codes (or messages)
@ -82,45 +82,45 @@ class CUnits // extends CommonObject
public function create($user, $notrigger = 0)
{
global $conf, $langs;
$error=0;
$error = 0;
// Clean parameters
if (isset($this->id)) $this->id = (int) $this->id;
if (isset($this->code)) $this->code=trim($this->code);
if (isset($this->label)) $this->libelle=trim($this->label);
if (isset($this->short_label)) $this->libelle=trim($this->short_label);
if (isset($this->unit_type)) $this->active=trim($this->unit_type);
if (isset($this->active)) $this->active=trim($this->active);
if (isset($this->scale)) $this->scale=trim($this->scale);
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->label)) $this->libelle = trim($this->label);
if (isset($this->short_label)) $this->libelle = trim($this->short_label);
if (isset($this->unit_type)) $this->active = trim($this->unit_type);
if (isset($this->active)) $this->active = trim($this->active);
if (isset($this->scale)) $this->scale = trim($this->scale);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units(";
$sql.= "rowid,";
$sql.= "code,";
$sql.= "label,";
$sql.= "short_label,";
$sql.= "unit_type";
$sql.= "scale";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").",";
$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
$sql.= " ".(! isset($this->short_label)?'NULL':"'".$this->db->escape($this->short_label)."'").",";
$sql.= " ".(! isset($this->unit_type)?'NULL':"'".$this->db->escape($this->unit_type)."'");
$sql.= " ".(! isset($this->scale)?'NULL':"'".$this->db->escape($this->scale)."'");
$sql.= ")";
$sql .= "rowid,";
$sql .= "code,";
$sql .= "label,";
$sql .= "short_label,";
$sql .= "unit_type";
$sql .= "scale";
$sql .= ") VALUES (";
$sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").",";
$sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").",";
$sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").",";
$sql .= " ".(!isset($this->short_label) ? 'NULL' : "'".$this->db->escape($this->short_label)."'").",";
$sql .= " ".(!isset($this->unit_type) ? 'NULL' : "'".$this->db->escape($this->unit_type)."'");
$sql .= " ".(!isset($this->scale) ? 'NULL' : "'".$this->db->escape($this->scale)."'");
$sql .= ")";
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (! $error)
if (!$error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units");
@ -141,13 +141,13 @@ class CUnits // extends CommonObject
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1*$error;
return -1 * $error;
}
else
{
@ -171,32 +171,32 @@ class CUnits // extends CommonObject
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.code,";
$sql.= " t.label,";
$sql.= " t.short_label,";
$sql.= " t.scale,";
$sql.= " t.unit_type,";
$sql.= " t.scale,";
$sql.= " t.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_units as t";
$sql_where=array();
if ($id) $sql_where[]= " t.id = ".$id;
if ($unit_type) $sql_where[]= " t.unit_type = '".$this->db->escape($unit_type)."'";
if ($code) $sql_where[]= " t.code = '".$this->db->escape($code)."'";
if ($short_label) $sql_where[]= " t.short_label = '".$this->db->escape($short_label)."'";
if (count($sql_where)>0) {
$sql.=' WHERE '. implode(' AND ', $sql_where);
$sql .= " t.rowid,";
$sql .= " t.code,";
$sql .= " t.label,";
$sql .= " t.short_label,";
$sql .= " t.scale,";
$sql .= " t.unit_type,";
$sql .= " t.scale,";
$sql .= " t.active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_units as t";
$sql_where = array();
if ($id) $sql_where[] = " t.id = ".$id;
if ($unit_type) $sql_where[] = " t.unit_type = '".$this->db->escape($unit_type)."'";
if ($code) $sql_where[] = " t.code = '".$this->db->escape($code)."'";
if ($short_label) $sql_where[] = " t.short_label = '".$this->db->escape($short_label)."'";
if (count($sql_where) > 0) {
$sql .= ' WHERE '.implode(' AND ', $sql_where);
}
$resql=$this->db->query($sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->id = $obj->rowid;
$this->code = $obj->code;
$this->label = $obj->label;
$this->short_label = $obj->short_label;
@ -211,7 +211,7 @@ class CUnits // extends CommonObject
}
else
{
$this->error="Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
@ -295,8 +295,8 @@ class CUnits // extends CommonObject
return $this->records;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
return -1;
}
@ -313,34 +313,34 @@ class CUnits // extends CommonObject
public function update($user = null, $notrigger = 0)
{
global $conf, $langs;
$error=0;
$error = 0;
// Clean parameters
if (isset($this->code)) $this->code=trim($this->code);
if (isset($this->label)) $this->libelle=trim($this->label);
if (isset($this->short_label)) $this->libelle=trim($this->short_label);
if (isset($this->unit_type)) $this->libelle=trim($this->unit_type);
if (isset($this->scale)) $this->scale=trim($this->scale);
if (isset($this->active)) $this->active=trim($this->active);
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->label)) $this->libelle = trim($this->label);
if (isset($this->short_label)) $this->libelle = trim($this->short_label);
if (isset($this->unit_type)) $this->libelle = trim($this->unit_type);
if (isset($this->scale)) $this->scale = trim($this->scale);
if (isset($this->active)) $this->active = trim($this->active);
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET";
$sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").",";
$sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " short_label=".(isset($this->short_label)?"'".$this->db->escape($this->short_label)."'":"null").",";
$sql.= " unit_type=".(isset($this->unit_type)?"'".$this->db->escape($this->unit_type)."'":"null").",";
$sql.= " scale=".(isset($this->scale)?"'".$this->db->escape($this->scale)."'":"null").",";
$sql.= " active=".(isset($this->active)?$this->active:"null");
$sql.= " WHERE rowid=".$this->id;
$sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").",";
$sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
$sql .= " short_label=".(isset($this->short_label) ? "'".$this->db->escape($this->short_label)."'" : "null").",";
$sql .= " unit_type=".(isset($this->unit_type) ? "'".$this->db->escape($this->unit_type)."'" : "null").",";
$sql .= " scale=".(isset($this->scale) ? "'".$this->db->escape($this->scale)."'" : "null").",";
$sql .= " active=".(isset($this->active) ? $this->active : "null");
$sql .= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
//if (! $error)
//{
@ -361,13 +361,13 @@ class CUnits // extends CommonObject
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1*$error;
return -1 * $error;
}
else
{
@ -387,16 +387,16 @@ class CUnits // extends CommonObject
public function delete($user, $notrigger = 0)
{
global $conf, $langs;
$error=0;
$error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_units";
$sql.= " WHERE rowid=".$this->id;
$sql .= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
//if (! $error)
//{
@ -417,13 +417,13 @@ class CUnits // extends CommonObject
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1*$error;
return -1 * $error;
}
else
{

View File

@ -22,15 +22,15 @@
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
require '../../main.inc.php'; // Load $user and permissions
require '../../main.inc.php'; // Load $user and permissions
require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
$idbom = GETPOST('idbom', 'alpha');
@ -42,7 +42,7 @@ $action = GETPOST('action', 'alpha');
*/
$object = new BOM($db);
$result=$object->fetch($idbom);
$result = $object->fetch($idbom);
if ($result > 0)
{
// We remove properties we don't need in answer

View File

@ -37,11 +37,11 @@ class FormProduct
/**
* @var string Error code (or message)
*/
public $error='';
public $error = '';
// Cache arrays
public $cache_warehouses=array();
public $cache_lot=array();
public $cache_warehouses = array();
public $cache_lot = array();
/**
@ -76,7 +76,7 @@ class FormProduct
{
global $conf, $langs;
if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product
if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product
if (is_array($exclude)) $excludeGroups = implode("','", $exclude);
@ -100,59 +100,59 @@ class FormProduct
{
if (!empty($batch))
{
$sql.= ", pb.qty as stock";
$sql .= ", pb.qty as stock";
}
else
{
$sql.= ", ps.reel as stock";
$sql .= ", ps.reel as stock";
}
}
elseif ($sumStock)
{
$sql.= ", sum(ps.reel) as stock";
$sql .= ", sum(ps.reel) as stock";
}
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid";
if (!empty($fk_product))
{
$sql.= " AND ps.fk_product = '".$fk_product."'";
$sql .= " AND ps.fk_product = '".$fk_product."'";
if (!empty($batch))
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'";
}
}
$sql.= " WHERE e.entity IN (".getEntity('stock').")";
$sql .= " WHERE e.entity IN (".getEntity('stock').")";
if (count($warehouseStatus))
{
$sql.= " AND e.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")";
$sql .= " AND e.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")";
}
else
{
$sql.= " AND e.statut = 1";
$sql .= " AND e.statut = 1";
}
if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')';
if (!empty($exclude)) $sql .= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')';
// minimum stock
if ($stockMin !== false) {
if (!empty($fk_product)) {
if (!empty($batch)) {
$sql .= " AND pb.qty > " . $this->db->escape($stockMin);
$sql .= " AND pb.qty > ".$this->db->escape($stockMin);
} else {
$sql .= " AND ps.reel > " . $this->db->escape($stockMin);
$sql .= " AND ps.reel > ".$this->db->escape($stockMin);
}
}
}
if ($sumStock && empty($fk_product)) {
$sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent";
$sql .= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent";
// minimum stock
if ($stockMin !== false) {
$sql .= " HAVING sum(ps.reel) > " . $this->db->escape($stockMin);
$sql .= " HAVING sum(ps.reel) > ".$this->db->escape($stockMin);
}
}
$sql.= " ORDER BY " . $orderBy;
$sql .= " ORDER BY ".$orderBy;
dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG);
$resql = $this->db->query($sql);
@ -164,16 +164,16 @@ class FormProduct
{
$obj = $this->db->fetch_object($resql);
if ($sumStock) $obj->stock = price2num($obj->stock, 5);
$this->cache_warehouses[$obj->rowid]['id'] =$obj->rowid;
$this->cache_warehouses[$obj->rowid]['label']=$obj->label;
$this->cache_warehouses[$obj->rowid]['parent_id']=$obj->fk_parent;
$this->cache_warehouses[$obj->rowid]['id'] = $obj->rowid;
$this->cache_warehouses[$obj->rowid]['label'] = $obj->label;
$this->cache_warehouses[$obj->rowid]['parent_id'] = $obj->fk_parent;
$this->cache_warehouses[$obj->rowid]['description'] = $obj->description;
$this->cache_warehouses[$obj->rowid]['stock'] = $obj->stock;
$i++;
}
// Full label init
foreach($this->cache_warehouses as $obj_rowid=>$tab) {
foreach ($this->cache_warehouses as $obj_rowid=>$tab) {
$this->cache_warehouses[$obj_rowid]['full_label'] = $this->get_parent_path($tab);
}
@ -197,11 +197,11 @@ class FormProduct
private function get_parent_path($tab, $final_label = '')
{
//phpcs:enable
if(empty($final_label)) $final_label = $tab['label'];
if (empty($final_label)) $final_label = $tab['label'];
if(empty($tab['parent_id'])) return $final_label;
if (empty($tab['parent_id'])) return $final_label;
else {
if(!empty($this->cache_warehouses[$tab['parent_id']])) {
if (!empty($this->cache_warehouses[$tab['parent_id']])) {
$final_label = $this->cache_warehouses[$tab['parent_id']]['label'].' >> '.$final_label;
return $this->get_parent_path($this->cache_warehouses[$tab['parent_id']], $final_label);
}
@ -309,8 +309,8 @@ class FormProduct
print '</tr></table></form>';
} else {
if ($selected) {
require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php';
$warehousestatic=new Entrepot($this->db);
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
$warehousestatic = new Entrepot($this->db);
$warehousestatic->fetch($selected);
print $warehousestatic->getNomUrl();
} else {
@ -357,7 +357,7 @@ class FormProduct
$return = '';
// TODO Use a cache
require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$measuringUnits = new CUnits($db);
$filter = array();
@ -375,10 +375,10 @@ class FormProduct
dol_print_error($db);
return -1;
} else {
$return .= '<select class="flat" name="' . $name . '">';
$return .= '<select class="flat" name="'.$name.'">';
if ($adddefault || $adddefault === '')
{
$return .= '<option value="0">' . ($adddefault ? $langs->trans("Default") : ''). '</option>';
$return .= '<option value="0">'.($adddefault ? $langs->trans("Default") : '').'</option>';
}
foreach ($measuringUnits->records as $lines)
@ -392,7 +392,7 @@ class FormProduct
elseif ($mode == 2 && $lines->scale == $default) $return .= ' selected';
elseif ($mode == 0 && $lines->id == $default) $return .= ' selected';
$return .= '>';
if ($measuring_style == 'time') $return.= $langs->trans(ucfirst($lines->label));
if ($measuring_style == 'time') $return .= $langs->trans(ucfirst($lines->label));
else $return .= $langs->trans($lines->label);
$return .= '</option>';
}
@ -426,11 +426,11 @@ class FormProduct
dol_syslog(get_class($this)."::selectLot $selected, $htmlname, $filterstatus, $empty, $disabled, $fk_product, $fk_entrepot, $empty_label, $forcecombo, $morecss", LOG_DEBUG);
$out='';
$out = '';
$productIdArray = array();
if (! is_array($objectLines) || ! count($objectLines))
if (!is_array($objectLines) || !count($objectLines))
{
if (! empty($fk_product)) $productIdArray[] = $fk_product;
if (!empty($fk_product)) $productIdArray[] = $fk_product;
}
else
{
@ -515,7 +515,7 @@ class FormProduct
// check cache already loaded for product id's
foreach ($productIdArray as $productId)
{
$cacheLoaded = ! empty($this->cache_lot[$productId]) ? true : false;
$cacheLoaded = !empty($this->cache_lot[$productId]) ? true : false;
}
}
if ($cacheLoaded)
@ -528,14 +528,14 @@ class FormProduct
$this->cache_lot = array();
$productIdList = implode(',', $productIdArray);
$sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product";
$sql.= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")";
$sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")";
if (!empty($productIdList))
{
$sql.= " WHERE ps.fk_product IN (".$productIdList.")";
$sql .= " WHERE ps.fk_product IN (".$productIdList.")";
}
$sql.= " ORDER BY e.ref, pb.batch";
$sql .= " ORDER BY e.ref, pb.batch";
dol_syslog(get_class($this).'::loadLotStock', LOG_DEBUG);
$resql = $this->db->query($sql);
@ -546,10 +546,10 @@ class FormProduct
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$this->cache_lot[$obj->fk_product][$obj->rowid]['id'] =$obj->rowid;
$this->cache_lot[$obj->fk_product][$obj->rowid]['batch']=$obj->batch;
$this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_id']=$obj->fk_entrepot;
$this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_label']=$obj->label;
$this->cache_lot[$obj->fk_product][$obj->rowid]['id'] = $obj->rowid;
$this->cache_lot[$obj->fk_product][$obj->rowid]['batch'] = $obj->batch;
$this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_id'] = $obj->fk_entrepot;
$this->cache_lot[$obj->fk_product][$obj->rowid]['entrepot_label'] = $obj->label;
$this->cache_lot[$obj->fk_product][$obj->rowid]['qty'] = $obj->qty;
$i++;
}

View File

@ -94,9 +94,9 @@ if (empty($reshook))
// Cancel
if ($cancel)
{
if (GETPOST("comefromclone")==1)
if (GETPOST("comefromclone") == 1)
{
$result=$object->delete($user);
$result = $object->delete($user);
if ($result > 0)
{
header("Location: index.php");
@ -119,7 +119,7 @@ if (empty($reshook))
if ($action == 'add' && $user->rights->projet->creer)
{
$error=0;
$error = 0;
if (empty($_POST["ref"]))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
@ -131,21 +131,21 @@ if (empty($reshook))
$error++;
}
if (GETPOST('opp_amount') != '' && ! (GETPOST('opp_status') > 0))
if (GETPOST('opp_amount') != '' && !(GETPOST('opp_status') > 0))
{
$error++;
setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
}
// Create with status validated immediatly
if (! empty($conf->global->PROJECT_CREATE_NO_DRAFT))
if (!empty($conf->global->PROJECT_CREATE_NO_DRAFT))
{
$status=Project::STATUS_VALIDATED;
$status = Project::STATUS_VALIDATED;
}
if (! $error)
if (!$error)
{
$error=0;
$error = 0;
$db->begin();
@ -156,23 +156,23 @@ if (empty($reshook))
$object->public = GETPOST('public', 'alpha');
$object->opp_amount = price2num(GETPOST('opp_amount', 'alpha'));
$object->budget_amount = price2num(GETPOST('budget_amount', 'alpha'));
$object->date_c = dol_now();
$object->date_c = dol_now();
$object->date_start = $date_start;
$object->date_end = $date_end;
$object->statut = $status;
$object->opp_status = $opp_status;
$object->opp_percent = $opp_percent;
$object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha')=='on'?1:0);
$object->usage_task = (GETPOST('usage_task', 'alpha')=='on'?1:0);
$object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha')=='on'?1:0);
$object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha')=='on'?1:0);
$object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0);
$object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0);
$object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0);
$object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
$result = $object->create($user);
if (! $error && $result > 0)
if (!$error && $result > 0)
{
// Add myself as project leader
$result = $object->add_contact($user->id, 'PROJECTLEADER', 'internal');
@ -189,26 +189,26 @@ if (empty($reshook))
setEventMessages($langs->trans($object->error), null, 'errors');
$error++;
}
if (! $error && !empty($object->id) > 0)
if (!$error && !empty($object->id) > 0)
{
// Category association
$categories = GETPOST('categories', 'array');
$result=$object->setCategories($categories);
if ($result<0) {
$result = $object->setCategories($categories);
if ($result < 0) {
$langs->load("errors");
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
if (! $error)
if (!$error)
{
$db->commit();
if (! empty($backtopage))
if (!empty($backtopage))
{
$backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation
$backtopage = $backtopage.'&projectid='.$object->id; // Old method
$backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation
$backtopage = $backtopage.'&projectid='.$object->id; // Old method
header("Location: ".$backtopage);
exit;
}
@ -231,9 +231,9 @@ if (empty($reshook))
}
}
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer)
{
$error=0;
$error = 0;
if (empty($ref))
{
@ -250,7 +250,7 @@ if (empty($reshook))
$db->begin();
if (! $error)
if (!$error)
{
$object->oldcopy = clone $object;
@ -260,18 +260,18 @@ if (empty($reshook))
$object->title = GETPOST('title', 'none'); // Do not use 'alpha' here, we want field as it is
$object->statut = GETPOST('status', 'int');
$object->socid = GETPOST('socid', 'int');
$object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is
$object->description = GETPOST('description', 'none'); // Do not use 'alpha' here, we want field as it is
$object->public = GETPOST('public', 'alpha');
$object->date_start = empty($_POST["projectstart"])?'':$date_start;
$object->date_end = empty($_POST["projectend"])?'':$date_end;
$object->date_start = empty($_POST["projectstart"]) ? '' : $date_start;
$object->date_end = empty($_POST["projectend"]) ? '' : $date_end;
if (isset($_POST['opp_amount'])) $object->opp_amount = price2num(GETPOST('opp_amount', 'alpha'));
if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount', 'alpha'));
if (isset($_POST['budget_amount'])) $object->budget_amount = price2num(GETPOST('budget_amount', 'alpha'));
if (isset($_POST['opp_status'])) $object->opp_status = $opp_status;
if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent;
$object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha')=='on'?1:0);
$object->usage_task = (GETPOST('usage_task', 'alpha')=='on'?1:0);
$object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha')=='on'?1:0);
$object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha')=='on'?1:0);
$object->usage_opportunity = (GETPOST('usage_opportunity', 'alpha') == 'on' ? 1 : 0);
$object->usage_task = (GETPOST('usage_task', 'alpha') == 'on' ? 1 : 0);
$object->usage_bill_time = (GETPOST('usage_bill_time', 'alpha') == 'on' ? 1 : 0);
$object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
@ -284,18 +284,18 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
}
if (! $error)
if (!$error)
{
$result=$object->update($user);
$result = $object->update($user);
if ($result < 0)
{
$error++;
if ($result == -4) setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors');
else setEventMessages($object->error, $object->errors, 'errors');
}else {
} else {
// Category association
$categories = GETPOST('categories', 'array');
$result=$object->setCategories($categories);
$result = $object->setCategories($categories);
if ($result < 0)
{
$error++;
@ -304,11 +304,11 @@ if (empty($reshook))
}
}
if (! $error)
if (!$error)
{
if (GETPOST("reportdate") && ($object->date_start!=$old_start_date))
if (GETPOST("reportdate") && ($object->date_start != $old_start_date))
{
$result=$object->shiftTaskDate($old_start_date);
$result = $object->shiftTaskDate($old_start_date);
if ($result < 0)
{
$error++;
@ -332,7 +332,7 @@ if (empty($reshook))
if ($error)
{
$db->rollback();
$action='edit';
$action = 'edit';
}
else
{
@ -355,11 +355,11 @@ if (empty($reshook))
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
}
$result= $object->generateDocument($object->modelpdf, $outputlangs);
$result = $object->generateDocument($object->modelpdf, $outputlangs);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$action='';
$action = '';
}
}
@ -368,11 +368,11 @@ if (empty($reshook))
{
if ($object->id > 0)
{
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$langs->load("other");
$upload_dir = $conf->projet->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
$file = $upload_dir.'/'.GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret)
setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
@ -413,7 +413,7 @@ if (empty($reshook))
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer)
{
$object->fetch($id);
$result=$object->delete($user);
$result = $object->delete($user);
if ($result > 0)
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
@ -429,15 +429,15 @@ if (empty($reshook))
if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes')
{
$clone_contacts=GETPOST('clone_contacts')?1:0;
$clone_tasks=GETPOST('clone_tasks')?1:0;
$clone_contacts = GETPOST('clone_contacts') ? 1 : 0;
$clone_tasks = GETPOST('clone_tasks') ? 1 : 0;
$clone_project_files = GETPOST('clone_project_files') ? 1 : 0;
$clone_task_files = GETPOST('clone_task_files') ? 1 : 0;
$clone_notes=GETPOST('clone_notes')?1:0;
$move_date=GETPOST('move_date')?1:0;
$clone_thirdparty=GETPOST('socid', 'int')?GETPOST('socid', 'int'):0;
$clone_notes = GETPOST('clone_notes') ? 1 : 0;
$move_date = GETPOST('move_date') ? 1 : 0;
$clone_thirdparty = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : 0;
$result=$object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty);
$result = $object->createFromClone($user, $object->id, $clone_contacts, $clone_tasks, $clone_project_files, $clone_task_files, $clone_notes, $move_date, 0, $clone_thirdparty);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
@ -445,21 +445,21 @@ if (empty($reshook))
else
{
// Load new object
$newobject=new Project($db);
$newobject = new Project($db);
$newobject->fetch($result);
$newobject->fetch_optionals();
$newobject->fetch_thirdparty(); // Load new object
$object=$newobject;
$action='edit';
$comefromclone=true;
$newobject->fetch_thirdparty(); // Load new object
$object = $newobject;
$action = 'edit';
$comefromclone = true;
}
}
// Actions to send emails
$trigger_name='PROJECT_SENTBYMAIL';
$paramname='id';
$autocopy='MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add
$trackid='proj'.$object->id;
$trigger_name = 'PROJECT_SENTBYMAIL';
$paramname = 'id';
$autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add
$trackid = 'proj'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}
@ -473,21 +473,21 @@ $formfile = new FormFile($db);
$formproject = new FormProjets($db);
$userstatic = new User($db);
$title=$langs->trans("Project").' - '.$object->ref.($object->thirdparty->name?' - '.$object->thirdparty->name:'').($object->title?' - '.$object->title:'');
if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) $title=$object->ref.($object->thirdparty->name?' - '.$object->thirdparty->name:'').($object->title?' - '.$object->title:'');
$help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
$title = $langs->trans("Project").' - '.$object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : '');
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) $title = $object->ref.($object->thirdparty->name ? ' - '.$object->thirdparty->name : '').($object->title ? ' - '.$object->title : '');
$help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
llxHeader("", $title, $help_url);
$titleboth=$langs->trans("LeadsOrProjects");
$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default
$titleboth = $langs->trans("LeadsOrProjects");
$titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default
if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0)
{
$titleboth=$langs->trans("Projects");
$titleboth = $langs->trans("Projects");
$titlenew = $langs->trans("NewProject");
}
if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
$titleboth=$langs->trans("Leads");
$titleboth = $langs->trans("Leads");
$titlenew = $langs->trans("NewLead");
}
@ -497,7 +497,7 @@ if ($action == 'create' && $user->rights->projet->creer)
* Create
*/
$thirdparty=new Societe($db);
$thirdparty = new Societe($db);
if ($socid > 0) $thirdparty->fetch($socid);
print load_fiche_titre($titlenew, '', 'project');
@ -511,18 +511,18 @@ if ($action == 'create' && $user->rights->projet->creer)
print '<table class="border centpercent tableforfieldcreate">';
$defaultref='';
$modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON;
$defaultref = '';
$modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON;
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
$file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0);
$file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0);
if (file_exists($file))
{
$filefound=1;
$filefound = 1;
$classname = $modele;
break;
}
@ -530,16 +530,16 @@ if ($action == 'create' && $user->rights->projet->creer)
if ($filefound)
{
$result=dol_include_once($reldir."core/modules/project/".$modele.'.php');
$result = dol_include_once($reldir."core/modules/project/".$modele.'.php');
$modProject = new $classname;
$defaultref = $modProject->getNextValue($thirdparty, $object);
}
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = '';
// Ref
$suggestedref=($_POST["ref"]?$_POST["ref"]:$defaultref);
$suggestedref = ($_POST["ref"] ? $_POST["ref"] : $defaultref);
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="12" type="text" name="ref" value="'.dol_escape_htmltag($suggestedref).'">';
print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref));
print '</td></tr>';
@ -552,23 +552,23 @@ if ($action == 'create' && $user->rights->projet->creer)
print $langs->trans("Usage");
print '</td>';
print '<td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<input type="checkbox" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha')!=''?' checked="checked"':'') : ' checked="checked"').'"> ';
print '<input type="checkbox" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ' checked="checked"').'"> ';
$htmltext = $langs->trans("ProjectFollowOpportunity");
print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
print '<br>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<input type="checkbox" name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha')!=''?' checked="checked"':'') : ' checked="checked"').'"> ';
print '<input type="checkbox" name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ' checked="checked"').'"> ';
$htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print '<br>';
}
if (! empty($conf->global->PROJECT_BILL_TIME_SPENT))
if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
{
print '<input type="checkbox" name="usage_bill_time"'.(GETPOST('usage_bill_time', 'alpha')!=''?' checked="checked"':'').'"> ';
print '<input type="checkbox" name="usage_bill_time"'.(GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '').'"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print '<br>';
@ -584,20 +584,20 @@ if ($action == 'create' && $user->rights->projet->creer)
if ($conf->societe->enabled)
{
print '<tr><td>';
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'<span class="fieldrequired">');
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '<span class="fieldrequired">');
print $langs->trans("ThirdParty");
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'</span>');
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '</span>');
print '</td><td class="maxwidthonsmartphone">';
$filteronlist='';
if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
$text=$form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300');
$filteronlist = '';
if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
$text = $form->select_company(GETPOST('socid', 'int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300');
if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile))
{
$texthelp=$langs->trans("IfNeedToUseOtherObjectKeepEmpty");
$texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty");
print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1);
}
else print $text;
if (! GETPOSTISSET('backtopage')) print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
if (!GETPOSTISSET('backtopage')) print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
print '</td></tr>';
}
@ -612,46 +612,46 @@ if ($action == 'create' && $user->rights->projet->creer)
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td class="maxwidthonsmartphone">';
$array=array();
$array = array();
if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject");
if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject");
print $form->selectarray('public', $array, GETPOST('public')?GETPOST('public'):$object->public);
print $form->selectarray('public', $array, GETPOST('public') ?GETPOST('public') : $object->public);
print '</td></tr>';
// Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print $form->selectDate(($date_start?$date_start:''), 'projectstart', 0, 0, 0, '', 1, 0);
print $form->selectDate(($date_start ? $date_start : ''), 'projectstart', 0, 0, 0, '', 1, 0);
print '</td></tr>';
// Date end
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
print $form->selectDate(($date_end?$date_end:-1), 'projectend', 0, 0, 0, '', 1, 0);
print $form->selectDate(($date_end ? $date_end : -1), 'projectend', 0, 0, 0, '', 1, 0);
print '</td></tr>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
// Opportunity status
print '<tr><td>'.$langs->trans("OpportunityStatus").'</td>';
print '<td class="maxwidthonsmartphone">';
print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status')?GETPOST('opp_status'):$object->opp_status);
print $formproject->selectOpportunityStatus('opp_status', GETPOST('opp_status') ?GETPOST('opp_status') : $object->opp_status);
print '</tr>';
// Opportunity probability
print '<tr><td>'.$langs->trans("OpportunityProbability").'</td>';
print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.dol_escape_htmltag(GETPOST('opp_percent')!=''?GETPOST('opp_percent'):'').'"><span class="hideonsmartphone"> %</span>';
print '<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.dol_escape_htmltag(GETPOST('opp_percent')!=''?'0':'1').'">';
print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.dol_escape_htmltag(GETPOST('opp_percent') != '' ?GETPOST('opp_percent') : '').'"><span class="hideonsmartphone"> %</span>';
print '<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.dol_escape_htmltag(GETPOST('opp_percent') != '' ? '0' : '1').'">';
print '</td>';
print '</tr>';
// Opportunity amount
print '<tr><td>'.$langs->trans("OpportunityAmount").'</td>';
print '<td><input size="5" type="text" name="opp_amount" value="'.dol_escape_htmltag(GETPOST('opp_amount')!=''?GETPOST('opp_amount'):'').'"></td>';
print '<td><input size="5" type="text" name="opp_amount" value="'.dol_escape_htmltag(GETPOST('opp_amount') != '' ?GETPOST('opp_amount') : '').'"></td>';
print '</tr>';
}
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td>';
print '<td><input size="5" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOST('budget_amount')!=''?GETPOST('budget_amount'):'').'"></td>';
print '<td><input size="5" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOST('budget_amount') != '' ?GETPOST('budget_amount') : '').'"></td>';
print '</tr>';
// Description
@ -664,14 +664,14 @@ if ($action == 'create' && $user->rights->projet->creer)
// Categories
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1);
$arrayselected=GETPOST('categories', 'array');
$arrayselected = GETPOST('categories', 'array');
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print "</td></tr>";
}
// Other options
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
@ -684,7 +684,7 @@ if ($action == 'create' && $user->rights->projet->creer)
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">';
if (! empty($backtopage))
if (!empty($backtopage))
{
print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
@ -692,7 +692,7 @@ if ($action == 'create' && $user->rights->projet->creer)
else
{
print ' &nbsp; &nbsp; ';
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
}
print '</div>';
@ -721,7 +721,7 @@ elseif ($object->id > 0)
* Show or edit
*/
$res=$object->fetch_optionals();
$res = $object->fetch_optionals();
// To verify role of users
$userAccess = $object->restrictedProjectArea($user, 'read');
@ -748,26 +748,26 @@ elseif ($object->id > 0)
// Confirmation delete
if ($action == 'delete')
{
$text=$langs->trans("ConfirmDeleteAProject");
$task=new Task($db);
$taskarray=$task->getTasksArray(0, 0, $object->id, 0, 0);
$nboftask=count($taskarray);
if ($nboftask) $text.='<br>'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask);
$text = $langs->trans("ConfirmDeleteAProject");
$task = new Task($db);
$taskarray = $task->getTasksArray(0, 0, $object->id, 0, 0);
$nboftask = count($taskarray);
if ($nboftask) $text .= '<br>'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks", $nboftask);
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAProject"), $text, "confirm_delete", '', '', 1);
}
// Clone confirmation
if ($action == 'clone')
{
$formquestion=array(
$formquestion = array(
'text' => $langs->trans("ConfirmClone"),
array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int')>0?GETPOST('socid', 'int'):$object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')),
array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true),
array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true),
array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true),
array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true),
array('type' => 'checkbox', 'name' => 'clone_project_files','label' => $langs->trans("CloneProjectFiles"), 'value' => false),
array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false)
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')),
array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true),
array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true),
array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true),
array('type' => 'checkbox', 'name' => 'clone_notes', 'label' => $langs->trans("CloneNotes"), 'value' => true),
array('type' => 'checkbox', 'name' => 'clone_project_files', 'label' => $langs->trans("CloneProjectFiles"), 'value' => false),
array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false)
);
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590);
@ -803,9 +803,9 @@ elseif ($object->id > 0)
// Status
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td><td>';
print '<select class="flat" name="status">';
foreach($object->statuts_short as $key => $val)
foreach ($object->statuts_short as $key => $val)
{
print '<option value="'.$key.'"'.((GETPOSTISSET('status')?GETPOST('status'):$object->statut) == $key ? ' selected="selected"':'').'>'.$langs->trans($val).'</option>';
print '<option value="'.$key.'"'.((GETPOSTISSET('status') ?GETPOST('status') : $object->statut) == $key ? ' selected="selected"' : '').'>'.$langs->trans($val).'</option>';
}
print '</select>';
print '</td></tr>';
@ -815,23 +815,23 @@ elseif ($object->id > 0)
print $langs->trans("Usage");
print '</td>';
print '<td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<input type="checkbox" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha')!=''?' checked="checked"':'') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
print '<input type="checkbox" name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowOpportunity");
print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
print '<br>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<input type="checkbox" name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha')!=''?' checked="checked"':'') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
print '<input type="checkbox" name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print '<br>';
}
if (! empty($conf->global->PROJECT_BILL_TIME_SPENT))
if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
{
print '<input type="checkbox" name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha')!=''?' checked="checked"':'') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
print '<input type="checkbox" name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print '<br>';
@ -842,16 +842,16 @@ elseif ($object->id > 0)
if ($conf->societe->enabled)
{
print '<tr><td>';
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'<span class="fieldrequired">');
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '<span class="fieldrequired">');
print $langs->trans("ThirdParty");
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'</span>');
print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) ? '' : '</span>');
print '</td><td>';
$filteronlist='';
if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
$text=$form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300');
$filteronlist = '';
if (!empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist = $conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
$text = $form->select_company($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), 0, 'minwidth300');
if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile))
{
$texthelp=$langs->trans("IfNeedToUseOtherObjectKeepEmpty");
$texthelp = $langs->trans("IfNeedToUseOtherObjectKeepEmpty");
print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2);
}
else print $text;
@ -860,13 +860,13 @@ elseif ($object->id > 0)
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
$array=array();
$array = array();
if (empty($conf->global->PROJECT_DISABLE_PRIVATE_PROJECT)) $array[0] = $langs->trans("PrivateProject");
if (empty($conf->global->PROJECT_DISABLE_PUBLIC_PROJECT)) $array[1] = $langs->trans("SharedProject");
print $form->selectarray('public', $array, $object->public);
print '</td></tr>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
// Opportunity status
print '<tr><td>'.$langs->trans("OpportunityStatus").'</td>';
@ -881,33 +881,33 @@ elseif ($object->id > 0)
// Opportunity probability
print '<tr><td>'.$langs->trans("OpportunityProbability").'</td>';
print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.(isset($_POST['opp_percent'])?GETPOST('opp_percent'):(strcmp($object->opp_percent, '')?vatrate($object->opp_percent):'')).'"> %';
print '<td><input size="5" type="text" id="opp_percent" name="opp_percent" value="'.(isset($_POST['opp_percent']) ?GETPOST('opp_percent') : (strcmp($object->opp_percent, '') ?vatrate($object->opp_percent) : '')).'"> %';
print '<span id="oldopppercent"></span>';
print '</td>';
print '</tr>';
// Opportunity amount
print '<tr><td>'.$langs->trans("OpportunityAmount").'</td>';
print '<td><input size="5" type="text" name="opp_amount" value="'.(isset($_POST['opp_amount'])?GETPOST('opp_amount'):(strcmp($object->opp_amount, '')?price2num($object->opp_amount):'')).'"></td>';
print '<td><input size="5" type="text" name="opp_amount" value="'.(isset($_POST['opp_amount']) ?GETPOST('opp_amount') : (strcmp($object->opp_amount, '') ?price2num($object->opp_amount) : '')).'"></td>';
print '</tr>';
}
// Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print $form->selectDate($object->date_start?$object->date_start:-1, 'projectstart', 0, 0, 0, '', 1, 0);
print $form->selectDate($object->date_start ? $object->date_start : -1, 'projectstart', 0, 0, 0, '', 1, 0);
print ' &nbsp; &nbsp; <input type="checkbox" class="valignmiddle" name="reportdate" value="yes" ';
if ($comefromclone){print ' checked ';}
print '/> '. $langs->trans("ProjectReportDate");
if ($comefromclone) {print ' checked '; }
print '/> '.$langs->trans("ProjectReportDate");
print '</td></tr>';
// Date end
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
print $form->selectDate($object->date_end?$object->date_end:-1, 'projectend', 0, 0, 0, '', 1, 0);
print $form->selectDate($object->date_end ? $object->date_end : -1, 'projectend', 0, 0, 0, '', 1, 0);
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td>';
print '<td><input size="5" type="text" name="budget_amount" value="'.(isset($_POST['budget_amount'])?GETPOST('budget_amount'):(strcmp($object->budget_amount, '')?price($object->budget_amount, 0, $langs, 1, 0):'')).'"></td>';
print '<td><input size="5" type="text" name="budget_amount" value="'.(isset($_POST['budget_amount']) ?GETPOST('budget_amount') : (strcmp($object->budget_amount, '') ?price($object->budget_amount, 0, $langs, 1, 0) : '')).'"></td>';
print '</tr>';
// Description
@ -923,7 +923,7 @@ elseif ($object->id > 0)
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1);
$c = new Categorie($db);
$cats = $c->containing($object->id, Categorie::TYPE_PROJECT);
foreach($cats as $cat) {
foreach ($cats as $cat) {
$arrayselected[] = $cat->id;
}
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
@ -931,8 +931,8 @@ elseif ($object->id > 0)
}
// Other options
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
@ -943,28 +943,28 @@ elseif ($object->id > 0)
}
else
{
dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public?'projectpub':'project'));
dol_fiche_head($head, 'project', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref = '<div class="refidno">';
// Title
$morehtmlref.=$object->title;
$morehtmlref .= $object->title;
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ';
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : ';
if ($object->thirdparty->id > 0)
{
$morehtmlref .= $object->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
$morehtmlref .= '</div>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
if (!$user->rights->projet->all->lire)
{
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
$object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")";
$object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@ -981,23 +981,23 @@ elseif ($object->id > 0)
print $langs->trans("Usage");
print '</td>';
print '<td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha')!=''?' checked="checked"':'') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowOpportunity");
print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
print '<br>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha')!=''?' checked="checked"':'') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print '<br>';
}
if (! empty($conf->global->PROJECT_BILL_TIME_SPENT))
if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
{
print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha')!=''?' checked="checked"':'') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print '<br>';
@ -1010,7 +1010,7 @@ elseif ($object->id > 0)
else print $langs->trans('PrivateProject');
print '</td></tr>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES) && ! empty($object->usage_opportunity))
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity))
{
// Opportunity status
print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>';
@ -1036,10 +1036,10 @@ elseif ($object->id > 0)
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
$start = dol_print_date($object->date_start, 'day');
print ($start?$start:'?');
print ($start ? $start : '?');
$end = dol_print_date($object->date_end, 'day');
print ' - ';
print ($end?$end:'?');
print ($end ? $end : '?');
if ($object->hasDelay()) print img_warning("Late");
print '</td></tr>';
@ -1050,7 +1050,7 @@ elseif ($object->id > 0)
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>';
@ -1067,7 +1067,7 @@ elseif ($object->id > 0)
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
if ($conf->categorie->enabled) {
print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($object->id, 'project', 1);
print "</td></tr>";
@ -1095,11 +1095,11 @@ elseif ($object->id > 0)
print '</form>';
// Change probability from status
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
// Default value to close or not when we set opp to 'WON'.
$defaultcheckedwhenoppclose=1;
if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0;
$defaultcheckedwhenoppclose = 1;
if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose = 0;
print '<!-- Javascript to manage opportunity status change -->';
print '<script type="text/javascript" language="javascript">
@ -1166,7 +1166,7 @@ elseif ($object->id > 0)
// modified by hook
if (empty($reshook))
{
if ($action != "edit" && $action != 'presend' )
if ($action != "edit" && $action != 'presend')
{
// Create event
/*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
@ -1179,7 +1179,7 @@ elseif ($object->id > 0)
// Send
if ($object->statut != 2)
{
print '<a class="butAction" href="card.php?id='.$object->id.'&amp;action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail').'</a>';
print '<a class="butAction" href="card.php?id='.$object->id.'&amp;action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>';
}
// Modify
@ -1235,54 +1235,54 @@ elseif ($object->id > 0)
}
// Add button to create objects from project
if (! empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON))
if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON))
{
if (! empty($conf->propal->enabled) && $user->rights->propal->creer)
if (!empty($conf->propal->enabled) && $user->rights->propal->creer)
{
$langs->load("propal");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddProp").'</a>';
}
if (! empty($conf->commande->enabled) && $user->rights->commande->creer)
if (!empty($conf->commande->enabled) && $user->rights->commande->creer)
{
$langs->load("orders");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateOrder").'</a>';
}
if (! empty($conf->facture->enabled) && $user->rights->facture->creer)
if (!empty($conf->facture->enabled) && $user->rights->facture->creer)
{
$langs->load("bills");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
}
if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer)
if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer)
{
$langs->load("supplier_proposal");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddSupplierProposal").'</a>';
}
if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->creer)
if (!empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->creer)
{
$langs->load("suppliers");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddSupplierOrder").'</a>';
}
if (! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->creer)
if (!empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->creer)
{
$langs->load("suppliers");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddSupplierInvoice").'</a>';
}
if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer)
if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer)
{
$langs->load("interventions");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddIntervention").'</a>';
}
if (! empty($conf->contrat->enabled) && $user->rights->contrat->creer)
if (!empty($conf->contrat->enabled) && $user->rights->contrat->creer)
{
$langs->load("contracts");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddContract").'</a>';
}
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->creer)
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->creer)
{
$langs->load("trips");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddTrip").'</a>';
}
if (! empty($conf->don->enabled) && $user->rights->don->creer)
if (!empty($conf->don->enabled) && $user->rights->don->creer)
{
$langs->load("donations");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddDonation").'</a>';
@ -1331,11 +1331,11 @@ elseif ($object->id > 0)
/*
* Documents generes
*/
$filename=dol_sanitizeFileName($object->ref);
$filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed=($user->rights->projet->lire && $userAccess > 0);
$delallowed=($user->rights->projet->creer && $userWrite > 0);
$filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = ($user->rights->projet->lire && $userAccess > 0);
$delallowed = ($user->rights->projet->creer && $userWrite > 0);
print $formfile->showdocuments('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf);
@ -1344,11 +1344,11 @@ elseif ($object->id > 0)
$MAXEVENT = 10;
$morehtmlright = '<a href="'.DOL_URL_ROOT.'/projet/info.php?id='.$object->id.'">';
$morehtmlright.= $langs->trans("SeeAll");
$morehtmlright.= '</a>';
$morehtmlright .= $langs->trans("SeeAll");
$morehtmlright .= '</a>';
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'project', 0, 1, '', $MAXEVENT, '', $morehtmlright);
@ -1356,17 +1356,17 @@ elseif ($object->id > 0)
}
// Presend form
$modelmail='project';
$defaulttopic='SendProjectRef';
$modelmail = 'project';
$defaulttopic = 'SendProjectRef';
$diroutput = $conf->projet->dir_output;
$autocopy='MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add
$autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add
$trackid = 'proj'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
// Hook to add more things on page
$parameters=array();
$reshook=$hookmanager->executeHooks('mainCardTabAddMore', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$parameters = array();
$reshook = $hookmanager->executeHooks('mainCardTabAddMore', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
}
else
{

View File

@ -43,16 +43,16 @@ $id = GETPOST('id', 'int');
* View
*/
if ($action=="getProducts") {
if ($action == "getProducts") {
$object = new Categorie($db);
$result=$object->fetch($category);
$result = $object->fetch($category);
if ($result > 0)
{
$prods = $object->getObjectsInCateg("product");
// Removed properties we don't need
if (is_array($prods) && count($prods) > 0)
{
foreach($prods as $prod)
foreach ($prods as $prod)
{
unset($prod->fields);
unset($prod->db);
@ -65,11 +65,11 @@ if ($action=="getProducts") {
echo 'Failed to load category with id='.$category;
}
}
elseif ($action=="search" && $term != '') {
elseif ($action == "search" && $term != '') {
$sql = 'SELECT rowid, ref, label, tosell, tobuy FROM '.MAIN_DB_PREFIX.'product';
$sql.= ' WHERE entity IN ('.getEntity('product').')';
$sql.= ' AND tosell = 1';
$sql.= natural_search(array('ref','label','barcode'), $term);
$sql .= ' WHERE entity IN ('.getEntity('product').')';
$sql .= ' AND tosell = 1';
$sql .= natural_search(array('ref', 'label', 'barcode'), $term);
$resql = $db->query($sql);
if ($resql)
{