Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into dev_resource_extrafields
This commit is contained in:
commit
5f3eb9097e
@ -164,10 +164,14 @@ class Skeleton_Class extends CommonObject
|
|||||||
$sql .= ' t.field2';
|
$sql .= ' t.field2';
|
||||||
//...
|
//...
|
||||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||||
|
$sql.= ' WHERE 1 = 1';
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("skeleton", 1) . ")";
|
||||||
|
}
|
||||||
if (null !== $ref) {
|
if (null !== $ref) {
|
||||||
$sql .= ' WHERE t.ref = ' . '\'' . $ref . '\'';
|
$sql .= ' AND t.ref = ' . '\'' . $ref . '\'';
|
||||||
} else {
|
} else {
|
||||||
$sql .= ' WHERE t.rowid = ' . $id;
|
$sql .= ' AND t.rowid = ' . $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -236,16 +240,20 @@ class Skeleton_Class extends CommonObject
|
|||||||
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
$sql.= ' WHERE 1 = 1';
|
||||||
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("skeleton", 1) . ")";
|
||||||
|
}
|
||||||
|
if (count($sqlwhere) > 0) {
|
||||||
|
$sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sortfield)) {
|
if (!empty($sortfield)) {
|
||||||
$sql .= $this->db->order($sortfield,$sortorder);
|
$sql .= $this->db->order($sortfield,$sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($limit)) {
|
if (!empty($limit)) {
|
||||||
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
|
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->lines = array();
|
$this->lines = array();
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -491,7 +499,7 @@ class Skeleton_Class extends CommonObject
|
|||||||
* Return the status
|
* Return the status
|
||||||
*
|
*
|
||||||
* @param int $status Id status
|
* @param int $status Id status
|
||||||
* @param int $mode 0=long label, 1=short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
|
||||||
* @return string Label of status
|
* @return string Label of status
|
||||||
*/
|
*/
|
||||||
static function LibStatut($status,$mode=0)
|
static function LibStatut($status,$mode=0)
|
||||||
@ -529,6 +537,11 @@ class Skeleton_Class extends CommonObject
|
|||||||
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
||||||
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||||
}
|
}
|
||||||
|
if ($mode == 6)
|
||||||
|
{
|
||||||
|
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
||||||
|
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ if (! $user->rights->accounting->bind->write)
|
|||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
// search & action GETPOST
|
// search & action GETPOST
|
||||||
$action = GETPOST('action');
|
$action = GETPOST('action', 'alpha');
|
||||||
$codeventil_buy = GETPOST('codeventil_buy', 'array');
|
$codeventil_buy = GETPOST('codeventil_buy', 'array');
|
||||||
$codeventil_sell = GETPOST('codeventil_sell', 'array');
|
$codeventil_sell = GETPOST('codeventil_sell', 'array');
|
||||||
$chk_prod = GETPOST('chk_prod', 'array');
|
$chk_prod = GETPOST('chk_prod', 'array');
|
||||||
@ -65,26 +65,32 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
|
|||||||
$btn_changeaccount = GETPOST('changeaccount');
|
$btn_changeaccount = GETPOST('changeaccount');
|
||||||
$btn_changetype = GETPOST('changetype');
|
$btn_changetype = GETPOST('changetype');
|
||||||
|
|
||||||
$sortfield = GETPOST('sortfield', 'alpha');
|
$limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
|
||||||
$sortorder = GETPOST('sortorder', 'alpha');
|
$sortfield = GETPOST("sortfield",'alpha');
|
||||||
$page = GETPOST('page', 'int');
|
$sortorder = GETPOST("sortorder",'alpha');
|
||||||
if ($page < 0)
|
$page = GETPOST("page",'int');
|
||||||
$page = 0;
|
if ($page == -1) { $page = 0; }
|
||||||
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
// bug in page limit if ACCOUNTING_LIMIT_LIST_VENTILATION < $conf->liste_limit there is no pagination displayed !
|
if (! $sortfield) $sortfield="p.ref";
|
||||||
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) && $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION >= $conf->liste_limit) {
|
if (! $sortorder) $sortorder="ASC";
|
||||||
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
|
|
||||||
} else {
|
|
||||||
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|
||||||
}
|
|
||||||
$offset = $limit * $page;
|
|
||||||
|
|
||||||
if (! $sortfield) {
|
if (empty($action)) $action='list';
|
||||||
$sortfield = "p.ref";
|
|
||||||
}
|
$arrayfields=array();
|
||||||
if (! $sortorder) {
|
|
||||||
$sortorder = "ASC";
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Purge search criteria
|
||||||
|
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
|
||||||
|
{
|
||||||
|
$search_ref = '';
|
||||||
|
$search_label = '';
|
||||||
|
$search_desc = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sales or Purchase mode ?
|
// Sales or Purchase mode ?
|
||||||
@ -158,6 +164,12 @@ if ($action == 'update') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
$form = new FormVentilation($db);
|
$form = new FormVentilation($db);
|
||||||
|
|
||||||
// Defaut AccountingAccount RowId Product / Service
|
// Defaut AccountingAccount RowId Product / Service
|
||||||
@ -175,44 +187,13 @@ $aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $c
|
|||||||
$aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
$aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||||
$aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
$aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||||
|
|
||||||
// Purge search criteria
|
|
||||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
|
|
||||||
{
|
|
||||||
$search_ref = '';
|
|
||||||
$search_label = '';
|
|
||||||
$search_desc = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* View
|
|
||||||
*/
|
|
||||||
|
|
||||||
llxHeader('', $langs->trans("ProductsBinding"));
|
llxHeader('', $langs->trans("ProductsBinding"));
|
||||||
|
|
||||||
print '<script type="text/javascript">
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||||
$(function () {
|
|
||||||
$(\'#select-all\').click(function(event) {
|
|
||||||
// Iterate each checkbox
|
|
||||||
$(\':checkbox\').each(function() {
|
|
||||||
this.checked = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$(\'#unselect-all\').click(function(event) {
|
|
||||||
// Iterate each checkbox
|
|
||||||
$(\':checkbox\').each(function() {
|
|
||||||
this.checked = false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>';
|
|
||||||
|
|
||||||
$sql = "SELECT p.rowid, p.ref, p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type";
|
$sql = "SELECT p.rowid, p.ref, p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
|
||||||
$sql .= " WHERE (";
|
$sql .= " WHERE (";
|
||||||
|
|
||||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
|
||||||
|
|
||||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') {
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') {
|
||||||
$sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL";
|
$sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL";
|
||||||
$sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN
|
$sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN
|
||||||
@ -222,39 +203,58 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') {
|
|||||||
$sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN
|
$sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN
|
||||||
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))";
|
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql.= ' AND p.entity IN ('.getEntity('product', 1).')';
|
||||||
|
}
|
||||||
// Add search filter like
|
// Add search filter like
|
||||||
if (strlen(trim($search_ref))) {
|
if (strlen(trim($search_ref))) {
|
||||||
$sql .= " AND (p.ref like '" . $search_ref . "%')";
|
$sql .= natural_search("p.ref",$search_ref);
|
||||||
}
|
}
|
||||||
if (strlen(trim($search_label))) {
|
if (strlen(trim($search_label))) {
|
||||||
$sql .= " AND (p.label like '" . $search_label . "%')";
|
$sql .= natural_search("p.label",$search_label);
|
||||||
}
|
}
|
||||||
if (strlen(trim($search_desc))) {
|
if (strlen(trim($search_desc))) {
|
||||||
$sql .= " AND (p.description like '%" . $search_desc . "%')";
|
$sql .= natural_search("p.description",$search_desc);
|
||||||
}
|
}
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
$nbtotalofrecords = 0;
|
||||||
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||||
|
{
|
||||||
|
$result = $db->query($sql);
|
||||||
|
$nbtotalofrecords = $db->num_rows($result);
|
||||||
|
}
|
||||||
$sql .= $db->plimit($limit + 1, $offset);
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
|
|
||||||
dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
|
dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result) {
|
if ($result)
|
||||||
$num_lines = $db->num_rows($result);
|
{
|
||||||
|
$num = $db->num_rows($result);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
|
$param='';
|
||||||
|
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||||
|
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||||
|
if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref);
|
||||||
|
if ($search_label > 0) $param.="&search_desc=".urlencode($search_label);
|
||||||
|
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
|
||||||
|
|
||||||
|
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
||||||
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
|
print '<input type="hidden" name="action" value="update">';
|
||||||
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy');
|
print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy');
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
print $langs->trans("InitAccountancyDesc") . '<br>';
|
print $langs->trans("InitAccountancyDesc") . '<br>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
// Select mode
|
||||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
|
||||||
print '<input type="hidden" name="action" value="update">';
|
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
|
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
|
||||||
@ -272,9 +272,15 @@ if ($result) {
|
|||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
|
|
||||||
print_barre_liste($langs->trans("ListOfProductsWithoutAccountingAccount"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines, '', '');
|
// Filter on categories
|
||||||
|
$moreforfilter='';
|
||||||
|
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||||
|
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
$texte=$langs->trans("ListOfProductsWithoutAccountingAccount");
|
||||||
|
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
|
||||||
|
|
||||||
|
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
|
||||||
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
|
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
|
||||||
@ -292,12 +298,11 @@ if ($result) {
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . $search_ref . '"></td>';
|
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
|
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . $search_desc . '"></td>';
|
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
|
||||||
|
|
||||||
print '<td class="liste_titre"> </td>';
|
print '<td class="liste_titre"> </td>';
|
||||||
print '<td align="center" class="liste_titre">';
|
print '<td align="right" class="liste_titre">';
|
||||||
$searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1);
|
$searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1);
|
||||||
print $searchpitco;
|
print $searchpitco;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -305,7 +310,8 @@ if ($result) {
|
|||||||
|
|
||||||
$var = true;
|
$var = true;
|
||||||
|
|
||||||
while ( $i < min($num_lines, 250) ) {
|
while ($i < min($num,$limit))
|
||||||
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
|
|
||||||
@ -374,14 +380,15 @@ if ($result) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checkbox select
|
// Checkbox select
|
||||||
print '<td align="center">';
|
print '<td align="right">';
|
||||||
print '<input type="checkbox" class="checkforselect" name="chk_prod[]" value="' . $obj->rowid . '"/></td>';
|
print '<input type="checkbox" class="checkforselect" name="chk_prod[]" value="' . $obj->rowid . '"/></td>';
|
||||||
|
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br><div align="right"><input type="submit" class="butAction" name="changeaccount" value="' . $langs->trans("Save") . '"></div>';
|
|
||||||
|
print '<br><div align="center"><input type="submit" class="butAction" name="changeaccount" value="' . $langs->trans("Save") . '"></div>';
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
$db->free($result);
|
$db->free($result);
|
||||||
|
|||||||
@ -110,7 +110,7 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int <0 if KO, Id of created object if OK
|
* @return int <0 if KO, Id of created object if OK
|
||||||
*/
|
*/
|
||||||
public function create(User $user, $notrigger = false) {
|
public function create(User $user, $notrigger = false) {
|
||||||
global $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
@ -184,6 +184,9 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " WHERE doc_type = '" . $this->doc_type . "'";
|
$sql .= " WHERE doc_type = '" . $this->doc_type . "'";
|
||||||
$sql .= " AND fk_docdet = " . $this->fk_docdet;
|
$sql .= " AND fk_docdet = " . $this->fk_docdet;
|
||||||
$sql .= " AND numero_compte = '" . $this->numero_compte . "'";
|
$sql .= " AND numero_compte = '" . $this->numero_compte . "'";
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
@ -197,6 +200,9 @@ class BookKeeping extends CommonObject
|
|||||||
$sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'";
|
$sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'";
|
||||||
$sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'";
|
$sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'";
|
||||||
$sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'";
|
$sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'";
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
|
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
|
||||||
$resqlnum = $this->db->query($sqlnum);
|
$resqlnum = $this->db->query($sqlnum);
|
||||||
@ -208,6 +214,9 @@ class BookKeeping extends CommonObject
|
|||||||
if (empty($this->piece_num)) {
|
if (empty($this->piece_num)) {
|
||||||
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
|
$sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum";
|
||||||
$sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
|
dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG);
|
||||||
$resqlnum = $this->db->query($sqlnum);
|
$resqlnum = $this->db->query($sqlnum);
|
||||||
@ -470,11 +479,12 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetch($id, $ref = null) {
|
public function fetch($id, $ref = null) {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'SELECT';
|
$sql = 'SELECT';
|
||||||
$sql .= ' t.rowid,';
|
$sql .= ' t.rowid,';
|
||||||
|
|
||||||
$sql .= " t.doc_date,";
|
$sql .= " t.doc_date,";
|
||||||
$sql .= " t.doc_type,";
|
$sql .= " t.doc_type,";
|
||||||
$sql .= " t.doc_ref,";
|
$sql .= " t.doc_ref,";
|
||||||
@ -491,7 +501,6 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " t.import_key,";
|
$sql .= " t.import_key,";
|
||||||
$sql .= " t.code_journal,";
|
$sql .= " t.code_journal,";
|
||||||
$sql .= " t.piece_num";
|
$sql .= " t.piece_num";
|
||||||
|
|
||||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||||
$sql .= ' WHERE 1 = 1';
|
$sql .= ' WHERE 1 = 1';
|
||||||
if (! empty($conf->multicompany->enabled)) {
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
@ -556,11 +565,12 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'SELECT';
|
$sql = 'SELECT';
|
||||||
$sql .= ' t.rowid,';
|
$sql .= ' t.rowid,';
|
||||||
|
|
||||||
$sql .= " t.doc_date,";
|
$sql .= " t.doc_date,";
|
||||||
$sql .= " t.doc_type,";
|
$sql .= " t.doc_type,";
|
||||||
$sql .= " t.doc_ref,";
|
$sql .= " t.doc_ref,";
|
||||||
@ -577,9 +587,6 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " t.import_key,";
|
$sql .= " t.import_key,";
|
||||||
$sql .= " t.code_journal,";
|
$sql .= " t.code_journal,";
|
||||||
$sql .= " t.piece_num";
|
$sql .= " t.piece_num";
|
||||||
|
|
||||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
|
||||||
|
|
||||||
// Manage filter
|
// Manage filter
|
||||||
$sqlwhere = array ();
|
$sqlwhere = array ();
|
||||||
if (count($filter) > 0) {
|
if (count($filter) > 0) {
|
||||||
@ -601,7 +608,6 @@ class BookKeeping extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql.= ' WHERE 1 = 1';
|
$sql.= ' WHERE 1 = 1';
|
||||||
if (! empty($conf->multicompany->enabled)) {
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
@ -672,11 +678,12 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'SELECT';
|
$sql = 'SELECT';
|
||||||
$sql .= ' t.rowid,';
|
$sql .= ' t.rowid,';
|
||||||
|
|
||||||
$sql .= " t.doc_date,";
|
$sql .= " t.doc_date,";
|
||||||
$sql .= " t.doc_type,";
|
$sql .= " t.doc_type,";
|
||||||
$sql .= " t.doc_ref,";
|
$sql .= " t.doc_ref,";
|
||||||
@ -693,9 +700,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " t.import_key,";
|
$sql .= " t.import_key,";
|
||||||
$sql .= " t.code_journal,";
|
$sql .= " t.code_journal,";
|
||||||
$sql .= " t.piece_num";
|
$sql .= " t.piece_num";
|
||||||
|
|
||||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||||
|
|
||||||
// Manage filter
|
// Manage filter
|
||||||
$sqlwhere = array ();
|
$sqlwhere = array ();
|
||||||
if (count($filter) > 0) {
|
if (count($filter) > 0) {
|
||||||
@ -715,7 +720,6 @@ class BookKeeping extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql.= ' WHERE 1 = 1';
|
$sql.= ' WHERE 1 = 1';
|
||||||
if (! empty($conf->multicompany->enabled)) {
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
@ -784,16 +788,15 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'SELECT';
|
$sql = 'SELECT';
|
||||||
$sql .= " t.numero_compte,";
|
$sql .= " t.numero_compte,";
|
||||||
$sql .= " SUM(t.debit) as debit,";
|
$sql .= " SUM(t.debit) as debit,";
|
||||||
$sql .= " SUM(t.credit) as credit";
|
$sql .= " SUM(t.credit) as credit";
|
||||||
|
|
||||||
|
|
||||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||||
|
|
||||||
// Manage filter
|
// Manage filter
|
||||||
$sqlwhere = array ();
|
$sqlwhere = array ();
|
||||||
if (count($filter) > 0) {
|
if (count($filter) > 0) {
|
||||||
@ -813,9 +816,12 @@ class BookKeeping extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$sql.= ' WHERE 1 = 1';
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= ' GROUP BY t.numero_compte';
|
$sql .= ' GROUP BY t.numero_compte';
|
||||||
@ -917,7 +923,6 @@ class BookKeeping extends CommonObject
|
|||||||
|
|
||||||
// Update request
|
// Update request
|
||||||
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
|
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
|
||||||
|
|
||||||
$sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ',';
|
$sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ',';
|
||||||
$sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ',';
|
$sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ',';
|
||||||
$sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ',';
|
$sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ',';
|
||||||
@ -934,7 +939,6 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ',';
|
$sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ',';
|
||||||
$sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ',';
|
$sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ',';
|
||||||
$sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null");
|
$sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null");
|
||||||
|
|
||||||
$sql .= ' WHERE rowid=' . $this->id;
|
$sql .= ' WHERE rowid=' . $this->id;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -1051,9 +1055,11 @@ class BookKeeping extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param string $delyear Year to delete
|
* @param string $delyear Year to delete
|
||||||
* @param string $journal Journal to delete
|
* @param string $journal Journal to delete
|
||||||
* @return int Result
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function deleteByYearAndJournal($delyear='', $journal='') {
|
function deleteByYearAndJournal($delyear='', $journal='') {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
if (empty($delyear) && empty($journal))
|
if (empty($delyear) && empty($journal))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -1067,6 +1073,9 @@ class BookKeeping extends CommonObject
|
|||||||
$sql.= " WHERE 1 = 1";
|
$sql.= " WHERE 1 = 1";
|
||||||
if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
|
if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
|
||||||
if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'";
|
if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'";
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if (! $resql) {
|
if (! $resql) {
|
||||||
@ -1090,12 +1099,17 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int Result
|
* @return int Result
|
||||||
*/
|
*/
|
||||||
function deleteMvtNum($piecenum) {
|
function deleteMvtNum($piecenum) {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// first check if line not yet in bookkeeping
|
// first check if line not yet in bookkeeping
|
||||||
$sql = "DELETE";
|
$sql = "DELETE";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= " WHERE piece_num = " . $piecenum;
|
$sql .= " WHERE piece_num = " . $piecenum;
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
@ -1193,9 +1207,14 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function fetchPerMvt($piecenum) {
|
public function fetchPerMvt($piecenum) {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
|
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= " WHERE piece_num = " . $piecenum;
|
$sql .= " WHERE piece_num = " . $piecenum;
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
|
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -1223,7 +1242,12 @@ class BookKeeping extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function getNextNumMvt()
|
public function getNextNumMvt()
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG);
|
dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -1247,12 +1271,17 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function fetch_all_per_mvt($piecenum) {
|
function fetch_all_per_mvt($piecenum) {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT rowid, doc_date, doc_type,";
|
$sql = "SELECT rowid, doc_date, doc_type,";
|
||||||
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
||||||
$sql .= " numero_compte, label_compte, debit, credit,";
|
$sql .= " numero_compte, label_compte, debit, credit,";
|
||||||
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= " WHERE piece_num = " . $piecenum;
|
$sql .= " WHERE piece_num = " . $piecenum;
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
|
dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -1297,11 +1326,16 @@ class BookKeeping extends CommonObject
|
|||||||
* @return int Result
|
* @return int Result
|
||||||
*/
|
*/
|
||||||
function export_bookkeping($model = 'ebp') {
|
function export_bookkeping($model = 'ebp') {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT rowid, doc_date, doc_type,";
|
$sql = "SELECT rowid, doc_date, doc_type,";
|
||||||
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
$sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,";
|
||||||
$sql .= " numero_compte, label_compte, debit, credit,";
|
$sql .= " numero_compte, label_compte, debit, credit,";
|
||||||
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG);
|
dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG);
|
||||||
|
|
||||||
@ -1352,10 +1386,9 @@ class BookKeeping extends CommonObject
|
|||||||
* @param string $htmlname Name of field in html form
|
* @param string $htmlname Name of field in html form
|
||||||
* @param int $showempty Add an empty field
|
* @param int $showempty Add an empty field
|
||||||
* @param array $event Event options
|
* @param array $event Event options
|
||||||
* @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1)
|
* @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1)
|
||||||
* @param int $select_out set value returned by select 0=rowid (default), 1=account_number
|
* @param int $select_out Set value returned by select 0=rowid (default), 1=account_number
|
||||||
* @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
|
* @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
|
||||||
*
|
|
||||||
* @return string String with HTML select
|
* @return string String with HTML select
|
||||||
*/
|
*/
|
||||||
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
|
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
|
||||||
@ -1371,6 +1404,9 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " AND aa.active = 1";
|
$sql .= " AND aa.active = 1";
|
||||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||||
$sql .= " AND asy.rowid = " . $pcgver;
|
$sql .= " AND asy.rowid = " . $pcgver;
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
$sql .= " ORDER BY account_number ASC";
|
$sql .= " ORDER BY account_number ASC";
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
|
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
|
||||||
@ -1389,7 +1425,6 @@ class BookKeeping extends CommonObject
|
|||||||
|
|
||||||
while ($obj = $this->db->fetch_object($resql)) {
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
|
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
|
||||||
$label = dol_trunc($label, $trunclength);
|
|
||||||
|
|
||||||
$select_value_in = $obj->rowid;
|
$select_value_in = $obj->rowid;
|
||||||
$select_value_out = $obj->rowid;
|
$select_value_out = $obj->rowid;
|
||||||
@ -1421,14 +1456,13 @@ class BookKeeping extends CommonObject
|
|||||||
* Description of a root accounting account
|
* Description of a root accounting account
|
||||||
*
|
*
|
||||||
* @param string $account Accounting account
|
* @param string $account Accounting account
|
||||||
* @return string
|
* @return string Root account
|
||||||
*/
|
*/
|
||||||
function get_compte_racine($account = null)
|
function get_compte_racine($account = null)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT root.account_number, root.label as label";
|
$sql = "SELECT root.account_number, root.label as label";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||||
@ -1438,7 +1472,9 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " WHERE aa.account_number = '" . $account . "'";
|
$sql .= " WHERE aa.account_number = '" . $account . "'";
|
||||||
$sql .= " AND parent.active = 1";
|
$sql .= " AND parent.active = 1";
|
||||||
$sql .= " AND root.active = 1";
|
$sql .= " AND root.active = 1";
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -1463,11 +1499,12 @@ class BookKeeping extends CommonObject
|
|||||||
* Description of accounting account
|
* Description of accounting account
|
||||||
*
|
*
|
||||||
* @param string $account Accounting account
|
* @param string $account Accounting account
|
||||||
* @return string
|
* @return string Account desc
|
||||||
*/
|
*/
|
||||||
function get_compte_desc($account = null)
|
function get_compte_desc($account = null)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||||
$sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category";
|
$sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa ";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa ";
|
||||||
@ -1476,6 +1513,10 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " AND asy.rowid = " . $pcgver;
|
$sql .= " AND asy.rowid = " . $pcgver;
|
||||||
$sql .= " AND aa.active = 1";
|
$sql .= " AND aa.active = 1";
|
||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
|
||||||
|
if (! empty($conf->multicompany->enabled)) {
|
||||||
|
$sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
@ -1499,6 +1540,7 @@ class BookKeeping extends CommonObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BookKeepingLine
|
* Class BookKeepingLine
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -377,92 +377,16 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
|
|||||||
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
$default_font_size = pdf_getPDFFontSize($outputlangs);
|
||||||
|
|
||||||
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
|
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
|
||||||
return pdf_pagefoot($pdf,$outputlangs,'BANK_CHEQUERECEIPT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
|
|
||||||
$paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT';
|
|
||||||
$marge_basse=$this->marge_basse;
|
|
||||||
$marge_gauche=$this->marge_gauche;
|
|
||||||
$page_hauteur=$this->page_hauteur;
|
|
||||||
|
|
||||||
// Line of free text
|
// Line of free text
|
||||||
$line=(! empty($conf->global->$paramfreetext))?$outputlangs->convToOutputCharset($conf->global->$paramfreetext):"";
|
$newfreetext='';
|
||||||
|
$paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT';
|
||||||
$pdf->SetFont('','', $default_font_size - 3);
|
if (! empty($conf->global->$paramfreetext))
|
||||||
$pdf->SetDrawColor(224,224,224);
|
|
||||||
|
|
||||||
// The start of the bottom of this page footer is positioned according to # of lines
|
|
||||||
$freetextheight=0;
|
|
||||||
if ($line) // Free text
|
|
||||||
{
|
{
|
||||||
//$line="eee<br>\nfd<strong>sf</strong>sdf<br>\nghfghg<br>";
|
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
|
||||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) // by default
|
|
||||||
{
|
|
||||||
$width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
|
|
||||||
if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
|
|
||||||
$width=200; $align='C';
|
|
||||||
}
|
}
|
||||||
$freetextheight=$pdf->getStringHeight($width,$line);
|
|
||||||
}
|
return pdf_pagefoot($pdf,$outputlangs,$newfreetext,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
|
||||||
else
|
|
||||||
{
|
|
||||||
$freetextheight=pdfGetHeightForHtmlContent($pdf,dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content)
|
|
||||||
//print '<br>'.$freetextheight;exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$marginwithfooter=$marge_basse + $freetextheight;
|
|
||||||
$posy=$marginwithfooter+0;
|
|
||||||
|
|
||||||
if ($line) // Free text
|
|
||||||
{
|
|
||||||
$pdf->SetXY($dims['lm'],-$posy);
|
|
||||||
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) // by default
|
|
||||||
{
|
|
||||||
$pdf->MultiCell(0, 3, $line, 0, $align, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk']-$marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0));
|
|
||||||
}
|
|
||||||
$posy-=$freetextheight;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On positionne le debut du bas de page selon nbre de lignes de ce bas de page
|
|
||||||
/*
|
|
||||||
$nbofline=dol_nboflines_bis($line,0,$outputlangs->charset_output);
|
|
||||||
//print 'e'.$line.'t'.dol_nboflines($line);exit;
|
|
||||||
$posy=$marge_basse + ($nbofline*3);
|
|
||||||
|
|
||||||
if ($line) // Free text
|
|
||||||
{
|
|
||||||
$pdf->SetXY($marge_gauche,-$posy);
|
|
||||||
$pdf->MultiCell(20000, 3, $line, 0, 'L', 0); // Use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
|
|
||||||
$posy-=($nbofline*3); // 6 of ligne + 3 of MultiCell
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$pdf->SetY(-$posy);
|
|
||||||
$pdf->line($marge_gauche, $page_hauteur-$posy, 200, $page_hauteur-$posy);
|
|
||||||
$posy--;
|
|
||||||
|
|
||||||
/*if ($line1)
|
|
||||||
{
|
|
||||||
$pdf->SetXY($marge_gauche,-$posy);
|
|
||||||
$pdf->MultiCell(200, 2, $line1, 0, 'C', 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($line2)
|
|
||||||
{
|
|
||||||
$posy-=3;
|
|
||||||
$pdf->SetXY($marge_gauche,-$posy);
|
|
||||||
$pdf->MultiCell(200, 2, $line2, 0, 'C', 0);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Show page nb only on iso languages (so default Helvetica font)
|
|
||||||
if (pdf_getPDFFont($outputlangs) == 'Helvetica')
|
|
||||||
{
|
|
||||||
$pdf->SetXY(-20,-$posy);
|
|
||||||
$pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -590,8 +590,6 @@ class pdf_einstein extends ModelePDFCommandes
|
|||||||
$this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
|
$this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->error=$langs->trans("ErrorUnknown");
|
|
||||||
return 0; // Erreur par defaut
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -406,8 +406,6 @@ class pdf_strato extends ModelePDFContract
|
|||||||
$this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR");
|
$this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->error=$langs->trans("ErrorUnknown");
|
|
||||||
return 0; // Erreur par defaut
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -269,8 +269,6 @@ class html_cerfafr extends ModeleDon
|
|||||||
$this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR");
|
$this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->error=$langs->trans("ErrorUnknown");
|
|
||||||
return 0; // Error by default
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -482,8 +482,6 @@ class pdf_standard extends ModeleExpenseReport
|
|||||||
$this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR");
|
$this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->error=$langs->trans("ErrorUnknown");
|
|
||||||
return 0; // Erreur par defaut
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -405,8 +405,6 @@ class pdf_soleil extends ModelePDFFicheinter
|
|||||||
$this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
|
$this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->error=$langs->trans("ErrorUnknown");
|
|
||||||
return 0; // Erreur par defaut
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -763,9 +763,6 @@ class pdf_azur extends ModelePDFPropales
|
|||||||
$this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
|
$this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->error=$langs->trans("ErrorUnknown");
|
|
||||||
return 0; // Erreur par defaut
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -549,8 +549,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
|
|||||||
$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
|
$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->error=$langs->trans("ErrorUnknown");
|
|
||||||
return 0; // Erreur par defaut
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -572,8 +572,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
|||||||
$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
|
$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->error=$langs->trans("ErrorUnknown");
|
|
||||||
return 0; // Erreur par defaut
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -198,8 +198,6 @@ class InterfaceLogevents extends DolibarrTriggers
|
|||||||
dol_syslog(get_class($this).": ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this).": ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -335,23 +335,23 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
$param='';
|
$param='';
|
||||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
|
||||||
if ($search_categ > 0) $param.="&search_categ=".$search_categ;
|
if ($search_categ > 0) $param.="&search_categ=".urlencode($search_categ);
|
||||||
if ($sref) $param="&sref=".$sref;
|
if ($sref) $param="&sref=".urlencode($sref);
|
||||||
if ($search_ref_supplier) $param="&search_ref_supplier=".$search_ref_supplier;
|
if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier);
|
||||||
if ($sbarcode) $param.=($sbarcode?"&sbarcode=".$sbarcode:"");
|
if ($sbarcode) $param.=($sbarcode?"&sbarcode=".urlencode($sbarcode):"");
|
||||||
if ($snom) $param.="&snom=".$snom;
|
if ($snom) $param.="&snom=".urlencode($snom);
|
||||||
if ($sall) $param.="&sall=".$sall;
|
if ($sall) $param.="&sall=".urlencode($sall);
|
||||||
if ($tosell != '') $param.="&tosell=".$tosell;
|
if ($tosell != '') $param.="&tosell=".urlencode($tosell);
|
||||||
if ($tobuy != '') $param.="&tobuy=".$tobuy;
|
if ($tobuy != '') $param.="&tobuy=".urlencode($tobuy);
|
||||||
if ($fourn_id) $param.=($fourn_id?"&fourn_id=".$fourn_id:"");
|
if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:"");
|
||||||
if ($seach_categ) $param.=($search_categ?"&search_categ=".$search_categ:"");
|
if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):"");
|
||||||
if ($type != '') $param.='&type='.urlencode($type);
|
if ($type != '') $param.='&type='.urlencode($type);
|
||||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
|
||||||
if ($search_tobatch) $param="&search_ref_supplier=".$search_ref_supplier;
|
if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier);
|
||||||
if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".$search_accountancy_code_sell;
|
if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell);
|
||||||
if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".$search_accountancy_code_buy;
|
if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy);
|
||||||
// Add $param from extra fields
|
// Add $param from extra fields
|
||||||
foreach ($search_array_options as $key => $val)
|
foreach ($search_array_options as $key => $val)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -260,7 +260,6 @@ abstract class ActionsCardCommon
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user