Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
9c4a2594b1
@ -6,6 +6,8 @@ English Dolibarr ChangeLog
|
|||||||
|
|
||||||
For developers:
|
For developers:
|
||||||
NEW: Add a lot of API REST: dictionaryevents, memberstypes, ...
|
NEW: Add a lot of API REST: dictionaryevents, memberstypes, ...
|
||||||
|
NEW: Big refactorization of multicompany transverse mode
|
||||||
|
NEW: getEntity function use true $shared value by default
|
||||||
|
|
||||||
WARNING:
|
WARNING:
|
||||||
|
|
||||||
@ -21,6 +23,8 @@ Following changes may create regression for some external modules, but were nece
|
|||||||
* Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used.
|
* Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used.
|
||||||
* Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still
|
* Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still
|
||||||
exists, but if an external module need action on it, it must provides itself its trigger file.
|
exists, but if an external module need action on it, it must provides itself its trigger file.
|
||||||
|
* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode
|
||||||
|
* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx')
|
||||||
|
|
||||||
***** ChangeLog for 5.0.3 compared to 5.0.2 *****
|
***** ChangeLog for 5.0.3 compared to 5.0.2 *****
|
||||||
FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty
|
FIX: #6677 Expired contracts dashboard box does not show the name of the thirdparty
|
||||||
|
|||||||
@ -218,7 +218,7 @@ else
|
|||||||
{
|
{
|
||||||
$sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
|
$sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
|
||||||
}
|
}
|
||||||
$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
|
$sql.= ' WHERE p.entity IN ('.getEntity('product').')';
|
||||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||||
if (strlen(trim($search_current_account))) {
|
if (strlen(trim($search_current_account))) {
|
||||||
$sql .= natural_search("p.accountancy_code_buy",$search_current_account);
|
$sql .= natural_search("p.accountancy_code_buy",$search_current_account);
|
||||||
|
|||||||
@ -466,7 +466,7 @@ print '</td>';
|
|||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
print price($total_credit);
|
print price($total_credit);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td></td>';
|
print '<td colspan="2"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|||||||
@ -85,6 +85,7 @@ class BookKeeping extends CommonObject
|
|||||||
public $fk_user_author;
|
public $fk_user_author;
|
||||||
public $import_key;
|
public $import_key;
|
||||||
public $code_journal;
|
public $code_journal;
|
||||||
|
public $journal_label;
|
||||||
public $piece_num;
|
public $piece_num;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,6 +157,9 @@ class BookKeeping extends CommonObject
|
|||||||
if (isset($this->code_journal)) {
|
if (isset($this->code_journal)) {
|
||||||
$this->code_journal = trim($this->code_journal);
|
$this->code_journal = trim($this->code_journal);
|
||||||
}
|
}
|
||||||
|
if (isset($this->journal_label)) {
|
||||||
|
$this->journal_label = trim($this->journal_label);
|
||||||
|
}
|
||||||
if (isset($this->piece_num)) {
|
if (isset($this->piece_num)) {
|
||||||
$this->piece_num = trim($this->piece_num);
|
$this->piece_num = trim($this->piece_num);
|
||||||
}
|
}
|
||||||
@ -189,7 +193,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " AND fk_doc = " . $this->fk_doc;
|
$sql .= " AND fk_doc = " . $this->fk_doc;
|
||||||
$sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines
|
$sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines
|
||||||
$sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'";
|
$sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'";
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
@ -203,7 +207,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank'
|
$sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank'
|
||||||
$sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ...
|
$sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ...
|
||||||
$sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object
|
$sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object
|
||||||
$sqlnum .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sqlnum .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
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);
|
||||||
@ -215,7 +219,7 @@ 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;
|
||||||
$sqlnum .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
$sqlnum .= " WHERE entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
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);
|
||||||
@ -250,6 +254,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= ", fk_user_author";
|
$sql .= ", fk_user_author";
|
||||||
$sql .= ", import_key";
|
$sql .= ", import_key";
|
||||||
$sql .= ", code_journal";
|
$sql .= ", code_journal";
|
||||||
|
$sql .= ", journal_label";
|
||||||
$sql .= ", piece_num";
|
$sql .= ", piece_num";
|
||||||
$sql .= ', entity';
|
$sql .= ', entity';
|
||||||
$sql .= ") VALUES (";
|
$sql .= ") VALUES (";
|
||||||
@ -268,6 +273,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= ",'" . $this->fk_user_author . "'";
|
$sql .= ",'" . $this->fk_user_author . "'";
|
||||||
$sql .= ",'" . $this->db->idate($this->date_create). "'";
|
$sql .= ",'" . $this->db->idate($this->date_create). "'";
|
||||||
$sql .= ",'" . $this->code_journal . "'";
|
$sql .= ",'" . $this->code_journal . "'";
|
||||||
|
$sql .= ",'" . $this->journal_label . "'";
|
||||||
$sql .= "," . $this->piece_num;
|
$sql .= "," . $this->piece_num;
|
||||||
$sql .= ", " . (! isset($this->entity) ? '1' : $this->entity);
|
$sql .= ", " . (! isset($this->entity) ? '1' : $this->entity);
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
@ -384,6 +390,9 @@ class BookKeeping extends CommonObject
|
|||||||
if (isset($this->code_journal)) {
|
if (isset($this->code_journal)) {
|
||||||
$this->code_journal = trim($this->code_journal);
|
$this->code_journal = trim($this->code_journal);
|
||||||
}
|
}
|
||||||
|
if (isset($this->journal_label)) {
|
||||||
|
$this->journal_label = trim($this->journal_label);
|
||||||
|
}
|
||||||
if (isset($this->piece_num)) {
|
if (isset($this->piece_num)) {
|
||||||
$this->piece_num = trim($this->piece_num);
|
$this->piece_num = trim($this->piece_num);
|
||||||
}
|
}
|
||||||
@ -410,6 +419,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= 'fk_user_author,';
|
$sql .= 'fk_user_author,';
|
||||||
$sql .= 'import_key,';
|
$sql .= 'import_key,';
|
||||||
$sql .= 'code_journal,';
|
$sql .= 'code_journal,';
|
||||||
|
$sql .= 'journal_label,';
|
||||||
$sql .= 'piece_num,';
|
$sql .= 'piece_num,';
|
||||||
$sql .= 'entity';
|
$sql .= 'entity';
|
||||||
$sql .= ') VALUES (';
|
$sql .= ') VALUES (';
|
||||||
@ -428,6 +438,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= ' ' . $user->id . ',';
|
$sql .= ' ' . $user->id . ',';
|
||||||
$sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ',';
|
$sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ',';
|
||||||
$sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ',';
|
$sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ',';
|
||||||
|
$sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ',';
|
||||||
$sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).',';
|
$sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).',';
|
||||||
$sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity);
|
$sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity);
|
||||||
$sql .= ')';
|
$sql .= ')';
|
||||||
@ -497,10 +508,11 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " t.fk_user_author,";
|
$sql .= " t.fk_user_author,";
|
||||||
$sql .= " t.import_key,";
|
$sql .= " t.import_key,";
|
||||||
$sql .= " t.code_journal,";
|
$sql .= " t.code_journal,";
|
||||||
|
$sql .= " t.journal_label,";
|
||||||
$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';
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
if (null !== $ref) {
|
if (null !== $ref) {
|
||||||
$sql .= ' AND t.ref = ' . '\'' . $ref . '\'';
|
$sql .= ' AND t.ref = ' . '\'' . $ref . '\'';
|
||||||
} else {
|
} else {
|
||||||
@ -530,6 +542,7 @@ class BookKeeping extends CommonObject
|
|||||||
$this->fk_user_author = $obj->fk_user_author;
|
$this->fk_user_author = $obj->fk_user_author;
|
||||||
$this->import_key = $obj->import_key;
|
$this->import_key = $obj->import_key;
|
||||||
$this->code_journal = $obj->code_journal;
|
$this->code_journal = $obj->code_journal;
|
||||||
|
$this->journal_label = $obj->journal_label;
|
||||||
$this->piece_num = $obj->piece_num;
|
$this->piece_num = $obj->piece_num;
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
@ -581,6 +594,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " t.fk_user_author,";
|
$sql .= " t.fk_user_author,";
|
||||||
$sql .= " t.import_key,";
|
$sql .= " t.import_key,";
|
||||||
$sql .= " t.code_journal,";
|
$sql .= " t.code_journal,";
|
||||||
|
$sql .= " t.journal_label,";
|
||||||
$sql .= " t.piece_num";
|
$sql .= " t.piece_num";
|
||||||
// Manage filter
|
// Manage filter
|
||||||
$sqlwhere = array ();
|
$sqlwhere = array ();
|
||||||
@ -605,7 +619,7 @@ class BookKeeping extends CommonObject
|
|||||||
}
|
}
|
||||||
$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';
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
@ -643,6 +657,7 @@ class BookKeeping extends CommonObject
|
|||||||
$line->fk_user_author = $obj->fk_user_author;
|
$line->fk_user_author = $obj->fk_user_author;
|
||||||
$line->import_key = $obj->import_key;
|
$line->import_key = $obj->import_key;
|
||||||
$line->code_journal = $obj->code_journal;
|
$line->code_journal = $obj->code_journal;
|
||||||
|
$line->journal_label = $obj->journal_label;
|
||||||
$line->piece_num = $obj->piece_num;
|
$line->piece_num = $obj->piece_num;
|
||||||
|
|
||||||
$this->lines[] = $line;
|
$this->lines[] = $line;
|
||||||
@ -693,6 +708,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " t.fk_user_author,";
|
$sql .= " t.fk_user_author,";
|
||||||
$sql .= " t.import_key,";
|
$sql .= " t.import_key,";
|
||||||
$sql .= " t.code_journal,";
|
$sql .= " t.code_journal,";
|
||||||
|
$sql .= " t.journal_label,";
|
||||||
$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
|
||||||
@ -715,7 +731,7 @@ class BookKeeping extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql.= ' WHERE 1 = 1';
|
$sql.= ' WHERE 1 = 1';
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
@ -752,6 +768,7 @@ class BookKeeping extends CommonObject
|
|||||||
$line->fk_user_author = $obj->fk_user_author;
|
$line->fk_user_author = $obj->fk_user_author;
|
||||||
$line->import_key = $obj->import_key;
|
$line->import_key = $obj->import_key;
|
||||||
$line->code_journal = $obj->code_journal;
|
$line->code_journal = $obj->code_journal;
|
||||||
|
$line->journal_label = $obj->journal_label;
|
||||||
$line->piece_num = $obj->piece_num;
|
$line->piece_num = $obj->piece_num;
|
||||||
|
|
||||||
$this->lines[] = $line;
|
$this->lines[] = $line;
|
||||||
@ -809,7 +826,7 @@ class BookKeeping extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql.= ' WHERE 1 = 1';
|
$sql.= ' WHERE 1 = 1';
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
if (count($sqlwhere) > 0) {
|
if (count($sqlwhere) > 0) {
|
||||||
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
@ -903,6 +920,9 @@ class BookKeeping extends CommonObject
|
|||||||
if (isset($this->code_journal)) {
|
if (isset($this->code_journal)) {
|
||||||
$this->code_journal = trim($this->code_journal);
|
$this->code_journal = trim($this->code_journal);
|
||||||
}
|
}
|
||||||
|
if (isset($this->journal_label)) {
|
||||||
|
$this->journal_label = trim($this->journal_label);
|
||||||
|
}
|
||||||
if (isset($this->piece_num)) {
|
if (isset($this->piece_num)) {
|
||||||
$this->piece_num = trim($this->piece_num);
|
$this->piece_num = trim($this->piece_num);
|
||||||
}
|
}
|
||||||
@ -927,6 +947,7 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= ' fk_user_author = ' . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ',';
|
$sql .= ' fk_user_author = ' . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ',';
|
||||||
$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 .= ' journal_label = ' . (isset($this->journal_label) ? "'" . $this->db->escape($this->journal_label) . "'" : "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;
|
||||||
|
|
||||||
@ -1062,7 +1083,7 @@ 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."'";
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if (! $resql) {
|
if (! $resql) {
|
||||||
@ -1094,7 +1115,7 @@ class BookKeeping extends CommonObject
|
|||||||
$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;
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
@ -1185,6 +1206,7 @@ class BookKeeping extends CommonObject
|
|||||||
$this->fk_user_author = $user->id;
|
$this->fk_user_author = $user->id;
|
||||||
$this->import_key = '';
|
$this->import_key = '';
|
||||||
$this->code_journal = '';
|
$this->code_journal = '';
|
||||||
|
$this->journal_label = '';
|
||||||
$this->piece_num = '';
|
$this->piece_num = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1197,10 +1219,10 @@ class BookKeeping extends CommonObject
|
|||||||
public function fetchPerMvt($piecenum) {
|
public function fetchPerMvt($piecenum) {
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type";
|
$sql = "SELECT piece_num,doc_date,code_journal,journal_label,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;
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
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);
|
||||||
@ -1209,6 +1231,7 @@ class BookKeeping extends CommonObject
|
|||||||
|
|
||||||
$this->piece_num = $obj->piece_num;
|
$this->piece_num = $obj->piece_num;
|
||||||
$this->code_journal = $obj->code_journal;
|
$this->code_journal = $obj->code_journal;
|
||||||
|
$this->journal_label = $obj->journal_label;
|
||||||
$this->doc_date = $this->db->jdate($obj->doc_date);
|
$this->doc_date = $this->db->jdate($obj->doc_date);
|
||||||
$this->doc_ref = $obj->doc_ref;
|
$this->doc_ref = $obj->doc_ref;
|
||||||
$this->doc_type = $obj->doc_type;
|
$this->doc_type = $obj->doc_type;
|
||||||
@ -1231,7 +1254,7 @@ class BookKeeping extends CommonObject
|
|||||||
global $conf;
|
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;
|
||||||
$sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " WHERE entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
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);
|
||||||
@ -1260,10 +1283,10 @@ class BookKeeping extends CommonObject
|
|||||||
$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, journal_label, 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;
|
||||||
$sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
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);
|
||||||
@ -1288,6 +1311,7 @@ class BookKeeping extends CommonObject
|
|||||||
$line->montant = $obj->montant;
|
$line->montant = $obj->montant;
|
||||||
$line->sens = $obj->sens;
|
$line->sens = $obj->sens;
|
||||||
$line->code_journal = $obj->code_journal;
|
$line->code_journal = $obj->code_journal;
|
||||||
|
$line->journal_label = $obj->journal_label;
|
||||||
$line->piece_num = $obj->piece_num;
|
$line->piece_num = $obj->piece_num;
|
||||||
|
|
||||||
$this->linesmvt[] = $line;
|
$this->linesmvt[] = $line;
|
||||||
@ -1315,7 +1339,7 @@ class BookKeeping extends CommonObject
|
|||||||
$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 entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " WHERE entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG);
|
dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG);
|
||||||
|
|
||||||
@ -1384,7 +1408,7 @@ 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;
|
||||||
$sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")";
|
||||||
$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);
|
||||||
@ -1449,7 +1473,7 @@ 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";
|
||||||
$sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " AND aa.entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
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);
|
||||||
@ -1488,7 +1512,7 @@ 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";
|
||||||
$sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql .= " WHERE aa.entity IN (" . getEntity('accountancy') . ")";
|
||||||
|
|
||||||
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);
|
||||||
@ -1533,5 +1557,6 @@ class BookKeepingLine
|
|||||||
public $fk_user_author;
|
public $fk_user_author;
|
||||||
public $import_key;
|
public $import_key;
|
||||||
public $code_journal;
|
public $code_journal;
|
||||||
|
public $journal_label;
|
||||||
public $piece_num;
|
public $piece_num;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,7 +93,7 @@ if (! empty($id)) {
|
|||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
|
||||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = l.fk_facture";
|
||||||
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
|
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
|
||||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||||
|
|
||||||
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
|
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|||||||
@ -141,7 +141,7 @@ if ($action == 'validatehistory') {
|
|||||||
$sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f";
|
$sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f";
|
||||||
$sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
|
$sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
|
||||||
$sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
|
$sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
|
||||||
$sql1.= " AND f.entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")";
|
||||||
$sql1.=")";
|
$sql1.=")";
|
||||||
|
|
||||||
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
||||||
@ -187,7 +187,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|||||||
} else {
|
} else {
|
||||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
||||||
}
|
}
|
||||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||||
|
|
||||||
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
|
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
@ -228,7 +228,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu
|
|||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||||
$sql .= " AND aa.account_number IS NULL";
|
$sql .= " AND aa.account_number IS NULL";
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
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 .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||||
@ -284,7 +284,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu
|
|||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
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 .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||||
} else {
|
} else {
|
||||||
@ -341,7 +341,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
|||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
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 .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||||
} else {
|
} else {
|
||||||
@ -387,7 +387,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
|||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||||
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
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 .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -164,7 +164,7 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factu
|
|||||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
$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 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
|
||||||
$sql .= " WHERE fd.fk_code_ventilation > 0 ";
|
$sql .= " WHERE fd.fk_code_ventilation > 0 ";
|
||||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||||
$sql .= " AND f.fk_statut > 0";
|
$sql .= " AND f.fk_statut > 0";
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
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 .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||||
@ -201,7 +201,7 @@ if (strlen(trim($search_country))) {
|
|||||||
if (strlen(trim($search_tvaintra))) {
|
if (strlen(trim($search_tvaintra))) {
|
||||||
$sql .= natural_search("s.tva_intra", $search_tva_intra);
|
$sql .= natural_search("s.tva_intra", $search_tva_intra);
|
||||||
}
|
}
|
||||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
// Count total nb of records
|
// Count total nb of records
|
||||||
|
|||||||
@ -220,7 +220,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|||||||
} else {
|
} 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 . ")";
|
||||||
}
|
}
|
||||||
$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||||
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,7 @@ if (! empty($id)) {
|
|||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
|
||||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
|
||||||
$sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id;
|
$sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id;
|
||||||
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||||
|
|
||||||
dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG);
|
dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|||||||
@ -134,7 +134,7 @@ if ($action == 'validatehistory') {
|
|||||||
$sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er";
|
$sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er";
|
||||||
$sql1.= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
|
$sql1.= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
|
||||||
$sql1.= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
|
$sql1.= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
|
||||||
$sql1.= " AND er.entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")";
|
||||||
$sql1.=")";
|
$sql1.=")";
|
||||||
|
|
||||||
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
||||||
@ -206,7 +206,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid =
|
|||||||
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND er.fk_statut > 0 ";
|
$sql .= " AND er.fk_statut > 0 ";
|
||||||
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||||
$sql .= " AND aa.account_number IS NULL";
|
$sql .= " AND aa.account_number IS NULL";
|
||||||
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
|
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid =
|
|||||||
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND er.fk_statut > 0 ";
|
$sql .= " AND er.fk_statut > 0 ";
|
||||||
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||||
$sql .= " AND aa.account_number IS NOT NULL";
|
$sql .= " AND aa.account_number IS NOT NULL";
|
||||||
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
|
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
|||||||
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND er.fk_statut > 0 ";
|
$sql .= " AND er.fk_statut > 0 ";
|
||||||
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||||
|
|
||||||
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql);
|
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql);
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
|
|||||||
@ -173,7 +173,7 @@ if (strlen(trim($search_account))) {
|
|||||||
if (strlen(trim($search_vat))) {
|
if (strlen(trim($search_vat))) {
|
||||||
$sql .= " AND (erd.tva_tx like '" . $search_vat . "%')";
|
$sql .= " AND (erd.tva_tx like '" . $search_vat . "%')";
|
||||||
}
|
}
|
||||||
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||||
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
|
|||||||
@ -203,7 +203,7 @@ if (strlen(trim($search_account))) {
|
|||||||
if (strlen(trim($search_vat))) {
|
if (strlen(trim($search_vat))) {
|
||||||
$sql .= natural_search("erd.tva_tx",$search_vat,1);
|
$sql .= natural_search("erd.tva_tx",$search_vat,1);
|
||||||
}
|
}
|
||||||
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||||
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
|
|||||||
@ -28,8 +28,6 @@
|
|||||||
* \brief Page with bank journal
|
* \brief Page with bank journal
|
||||||
*/
|
*/
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
// Class
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
|
||||||
@ -53,8 +51,6 @@ require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php';
|
||||||
|
|
||||||
|
|
||||||
// Langs
|
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
@ -77,6 +73,7 @@ $date_endyear = GETPOST('date_endyear');
|
|||||||
$action = GETPOST('action','aZ09');
|
$action = GETPOST('action','aZ09');
|
||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
$action = GETPOST('action','aZ09');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->societe_id > 0 && empty($id_journal))
|
if ($user->societe_id > 0 && empty($id_journal))
|
||||||
@ -140,6 +137,7 @@ $paymentexpensereportstatic = new PaymentExpenseReport($db);
|
|||||||
$accountingjournalstatic = new AccountingJournal($db);
|
$accountingjournalstatic = new AccountingJournal($db);
|
||||||
$accountingjournalstatic->fetch($id_journal);
|
$accountingjournalstatic->fetch($id_journal);
|
||||||
$journal = $accountingjournalstatic->code;
|
$journal = $accountingjournalstatic->code;
|
||||||
|
$journal_label = $accountingjournalstatic->label;
|
||||||
|
|
||||||
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
|
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
@ -361,6 +359,7 @@ if (! $error && $action == 'writebookkeeping') {
|
|||||||
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
$bookkeeping->debit = ($mt >= 0 ? $mt : 0);
|
||||||
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
|
$bookkeeping->credit = ($mt < 0 ? - $mt : 0);
|
||||||
$bookkeeping->code_journal = $journal;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
$bookkeeping->date_create = $now;
|
$bookkeeping->date_create = $now;
|
||||||
|
|
||||||
@ -454,6 +453,7 @@ if (! $error && $action == 'writebookkeeping') {
|
|||||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $journal;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
$bookkeeping->date_create = $now;
|
$bookkeeping->date_create = $now;
|
||||||
|
|
||||||
|
|||||||
@ -27,8 +27,6 @@
|
|||||||
* \brief Page with expense reports journal
|
* \brief Page with expense reports journal
|
||||||
*/
|
*/
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
// Class
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.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/accounting.lib.php';
|
||||||
@ -38,7 +36,6 @@ require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
||||||
|
|
||||||
// Langs
|
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
@ -46,8 +43,8 @@ $langs->load("main");
|
|||||||
$langs->load("accountancy");
|
$langs->load("accountancy");
|
||||||
$langs->load("trips");
|
$langs->load("trips");
|
||||||
|
|
||||||
// Multi journal
|
|
||||||
$id_journal = GETPOST('id_journal', 'int');
|
$id_journal = GETPOST('id_journal', 'int');
|
||||||
|
$action = GETPOST('action','aZ09');
|
||||||
|
|
||||||
$date_startmonth = GETPOST('date_startmonth');
|
$date_startmonth = GETPOST('date_startmonth');
|
||||||
$date_startday = GETPOST('date_startday');
|
$date_startday = GETPOST('date_startday');
|
||||||
@ -62,16 +59,15 @@ $now = dol_now();
|
|||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$action = GETPOST('action','aZ09');
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
// Get code of finance journal
|
|
||||||
|
// Get informations of journal
|
||||||
$accountingjournalstatic = new AccountingJournal($db);
|
$accountingjournalstatic = new AccountingJournal($db);
|
||||||
$accountingjournalstatic->fetch($id_journal);
|
$accountingjournalstatic->fetch($id_journal);
|
||||||
$journal = $accountingjournalstatic->code;
|
$journal = $accountingjournalstatic->code;
|
||||||
|
$journal_label = $accountingjournalstatic->label;
|
||||||
|
|
||||||
$year_current = strftime("%Y", dol_now());
|
$year_current = strftime("%Y", dol_now());
|
||||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||||
@ -105,7 +101,7 @@ $sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_ex
|
|||||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author";
|
$sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author";
|
||||||
$sql .= " WHERE er.fk_statut > 0 ";
|
$sql .= " WHERE er.fk_statut > 0 ";
|
||||||
$sql .= " AND erd.fk_code_ventilation > 0 ";
|
$sql .= " AND erd.fk_code_ventilation > 0 ";
|
||||||
$sql .= " AND er.entity IN (" . getEntity("expensereport", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
|
||||||
if ($date_start && $date_end)
|
if ($date_start && $date_end)
|
||||||
$sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'";
|
$sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'";
|
||||||
$sql .= " ORDER BY er.date_debut";
|
$sql .= " ORDER BY er.date_debut";
|
||||||
@ -187,6 +183,7 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
|
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
|
||||||
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $journal;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
@ -233,6 +230,7 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||||
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $journal;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
@ -277,6 +275,7 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||||
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $journal;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
@ -444,7 +443,7 @@ if (empty($action) || $action == 'view') {
|
|||||||
|
|
||||||
llxHeader('', $langs->trans("ExpenseReportsJournal"));
|
llxHeader('', $langs->trans("ExpenseReportsJournal"));
|
||||||
|
|
||||||
$nom = $langs->trans("ExpenseReportsJournal");
|
$nom = $langs->trans("ExpenseReportsJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1);
|
||||||
$nomlink = '';
|
$nomlink = '';
|
||||||
$periodlink = '';
|
$periodlink = '';
|
||||||
$exportlink = '';
|
$exportlink = '';
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||||
*
|
*
|
||||||
@ -27,23 +27,24 @@
|
|||||||
* \brief Page with purchases journal
|
* \brief Page with purchases journal
|
||||||
*/
|
*/
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
// Class
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.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/accounting.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
|
||||||
|
|
||||||
// Langs
|
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
$langs->load("main");
|
$langs->load("main");
|
||||||
$langs->load("accountancy");
|
$langs->load("accountancy");
|
||||||
|
|
||||||
|
$id_journal = GETPOST('id_journal', 'int');
|
||||||
|
$action = GETPOST('action','aZ09');
|
||||||
|
|
||||||
$date_startmonth = GETPOST('date_startmonth');
|
$date_startmonth = GETPOST('date_startmonth');
|
||||||
$date_startday = GETPOST('date_startday');
|
$date_startday = GETPOST('date_startday');
|
||||||
$date_startyear = GETPOST('date_startyear');
|
$date_startyear = GETPOST('date_startyear');
|
||||||
@ -57,13 +58,16 @@ $now = dol_now();
|
|||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$action = GETPOST('action','aZ09');
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Get informations of journal
|
||||||
|
$accountingjournalstatic = new AccountingJournal($db);
|
||||||
|
$accountingjournalstatic->fetch($id_journal);
|
||||||
|
$journal = $accountingjournalstatic->code;
|
||||||
|
$journal_label = $accountingjournalstatic->label;
|
||||||
|
|
||||||
$year_current = strftime("%Y", dol_now());
|
$year_current = strftime("%Y", dol_now());
|
||||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||||
$pastmonthyear = $year_current;
|
$pastmonthyear = $year_current;
|
||||||
@ -96,7 +100,7 @@ $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_factu
|
|||||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
||||||
$sql .= " WHERE f.fk_statut > 0 ";
|
$sql .= " WHERE f.fk_statut > 0 ";
|
||||||
$sql .= " AND fd.fk_code_ventilation > 0 ";
|
$sql .= " AND fd.fk_code_ventilation > 0 ";
|
||||||
$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
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
|
||||||
$sql .= " AND f.type IN (0,1,2)";
|
$sql .= " AND f.type IN (0,1,2)";
|
||||||
else
|
else
|
||||||
@ -217,7 +221,8 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
|
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
|
||||||
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
|
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
|
||||||
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
@ -263,7 +268,8 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
||||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||||
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
@ -307,7 +313,8 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
||||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||||
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
@ -337,7 +344,6 @@ if ($action == 'writebookkeeping') {
|
|||||||
{
|
{
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($error) && count($tabpay)) {
|
if (empty($error) && count($tabpay)) {
|
||||||
@ -351,7 +357,6 @@ if ($action == 'writebookkeeping') {
|
|||||||
{
|
{
|
||||||
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
|
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
|
||||||
}
|
}
|
||||||
|
|
||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +493,7 @@ if (empty($action) || $action == 'view') {
|
|||||||
|
|
||||||
llxHeader('', $langs->trans("PurchasesJournal"));
|
llxHeader('', $langs->trans("PurchasesJournal"));
|
||||||
|
|
||||||
$nom = $langs->trans("PurchasesJournal");
|
$nom = $langs->trans("PurchasesJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1);
|
||||||
$nomlink = '';
|
$nomlink = '';
|
||||||
$periodlink = '';
|
$periodlink = '';
|
||||||
$exportlink = '';
|
$exportlink = '';
|
||||||
@ -503,7 +508,9 @@ if (empty($action) || $action == 'view') {
|
|||||||
|
|
||||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||||
|
|
||||||
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
|
$varlink = 'id_journal=' . $id_journal;
|
||||||
|
|
||||||
|
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
|
||||||
|
|
||||||
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
|
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
|
||||||
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
|
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
|
||||||
@ -537,7 +544,6 @@ if (empty($action) || $action == 'view') {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
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("JournalNum")."</td>";
|
|
||||||
print "<td></td>";
|
print "<td></td>";
|
||||||
print "<td>" . $langs->trans("Date") . "</td>";
|
print "<td>" . $langs->trans("Date") . "</td>";
|
||||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||||
@ -590,6 +596,7 @@ if (empty($action) || $action == 'view') {
|
|||||||
print "</tr>";
|
print "</tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
foreach ( $tabtva[$key] as $k => $mt ) {
|
foreach ( $tabtva[$key] as $k => $mt ) {
|
||||||
if ($mt) {
|
if ($mt) {
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||||
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
@ -29,17 +29,15 @@
|
|||||||
* \brief Page with sells journal
|
* \brief Page with sells journal
|
||||||
*/
|
*/
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
// Class
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.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/accounting.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
|
|
||||||
|
|
||||||
// Langs
|
|
||||||
$langs->load("commercial");
|
$langs->load("commercial");
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -47,6 +45,9 @@ $langs->load("other");
|
|||||||
$langs->load("main");
|
$langs->load("main");
|
||||||
$langs->load("accountancy");
|
$langs->load("accountancy");
|
||||||
|
|
||||||
|
$id_journal = GETPOST('id_journal', 'int');
|
||||||
|
$action = GETPOST('action','aZ09');
|
||||||
|
|
||||||
$date_startmonth = GETPOST('date_startmonth');
|
$date_startmonth = GETPOST('date_startmonth');
|
||||||
$date_startday = GETPOST('date_startday');
|
$date_startday = GETPOST('date_startday');
|
||||||
$date_startyear = GETPOST('date_startyear');
|
$date_startyear = GETPOST('date_startyear');
|
||||||
@ -60,13 +61,17 @@ $now = dol_now();
|
|||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$action = GETPOST('action','aZ09');
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Get informations of journal
|
||||||
|
$accountingjournalstatic = new AccountingJournal($db);
|
||||||
|
$accountingjournalstatic->fetch($id_journal);
|
||||||
|
$journal = $accountingjournalstatic->code;
|
||||||
|
$journal_label = $accountingjournalstatic->label;
|
||||||
|
|
||||||
$year_current = strftime("%Y", dol_now());
|
$year_current = strftime("%Y", dol_now());
|
||||||
$pastmonth = strftime("%m", dol_now()) - 1;
|
$pastmonth = strftime("%m", dol_now()) - 1;
|
||||||
$pastmonthyear = $year_current;
|
$pastmonthyear = $year_current;
|
||||||
@ -234,7 +239,8 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||||
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
|
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
|
||||||
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
@ -278,7 +284,8 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||||
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
||||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
@ -321,7 +328,8 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||||
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
|
||||||
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
|
||||||
$bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
$bookkeeping->code_journal = $journal;
|
||||||
|
$bookkeeping->journal_label = $journal_label;
|
||||||
$bookkeeping->fk_user_author = $user->id;
|
$bookkeeping->fk_user_author = $user->id;
|
||||||
|
|
||||||
$result = $bookkeeping->create($user);
|
$result = $bookkeeping->create($user);
|
||||||
@ -505,7 +513,7 @@ if (empty($action) || $action == 'view') {
|
|||||||
|
|
||||||
llxHeader('', $langs->trans("SellsJournal"));
|
llxHeader('', $langs->trans("SellsJournal"));
|
||||||
|
|
||||||
$nom = $langs->trans("SellsJournal");
|
$nom = $langs->trans("SellsJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1);
|
||||||
$nomlink = '';
|
$nomlink = '';
|
||||||
$periodlink = '';
|
$periodlink = '';
|
||||||
$exportlink = '';
|
$exportlink = '';
|
||||||
@ -518,7 +526,9 @@ if (empty($action) || $action == 'view') {
|
|||||||
$description .= $langs->trans("DepositsAreIncluded");
|
$description .= $langs->trans("DepositsAreIncluded");
|
||||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||||
|
|
||||||
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
|
$varlink = 'id_journal=' . $id_journal;
|
||||||
|
|
||||||
|
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
|
||||||
|
|
||||||
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
|
/*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
|
||||||
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
|
print '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
|
||||||
|
|||||||
@ -96,7 +96,7 @@ if (! empty($id)) {
|
|||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON l.fk_code_ventilation = aa.rowid";
|
||||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn ";
|
||||||
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
|
$sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id;
|
||||||
$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
|
||||||
|
|
||||||
dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
|
dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|||||||
@ -134,7 +134,7 @@ if ($action == 'validatehistory') {
|
|||||||
$sql1.= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
|
$sql1.= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
|
||||||
$sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
|
$sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
|
||||||
$sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
|
$sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
|
||||||
$sql1.= " AND f.entity IN (" . getEntity("accountancy", 1) . ")";
|
$sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")";
|
||||||
$sql1.= ")";
|
$sql1.= ")";
|
||||||
|
|
||||||
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
|
||||||
@ -204,7 +204,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid
|
|||||||
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND ff.fk_statut > 0 ";
|
$sql .= " AND ff.fk_statut > 0 ";
|
||||||
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||||
$sql .= " AND aa.account_number IS NULL";
|
$sql .= " AND aa.account_number IS NULL";
|
||||||
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid
|
|||||||
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND ff.fk_statut > 0 ";
|
$sql .= " AND ff.fk_statut > 0 ";
|
||||||
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||||
$sql .= " AND aa.account_number IS NOT NULL";
|
$sql .= " AND aa.account_number IS NOT NULL";
|
||||||
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
|||||||
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
||||||
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
$sql .= " AND ff.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
||||||
$sql .= " AND ff.fk_statut > 0 ";
|
$sql .= " AND ff.fk_statut > 0 ";
|
||||||
$sql .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; // We don't share object for accountancy
|
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||||
|
|
||||||
dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
|
dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
|
|||||||
@ -182,7 +182,7 @@ if (strlen(trim($search_account))) {
|
|||||||
if (strlen(trim($search_vat))) {
|
if (strlen(trim($search_vat))) {
|
||||||
$sql .= natural_search("l.tva_tx", $search_vat, 1);
|
$sql .= natural_search("l.tva_tx", $search_vat, 1);
|
||||||
}
|
}
|
||||||
$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
|
||||||
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
|
|||||||
@ -217,7 +217,7 @@ if (strlen(trim($search_account))) {
|
|||||||
if (strlen(trim($search_vat))) {
|
if (strlen(trim($search_vat))) {
|
||||||
$sql .= natural_search("l.tva_tx",$search_vat,1);
|
$sql .= natural_search("l.tva_tx",$search_vat,1);
|
||||||
}
|
}
|
||||||
$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
|
||||||
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
|
|||||||
@ -1780,7 +1780,7 @@ class Adherent extends CommonObject
|
|||||||
$sql = "SELECT count(a.rowid) as nb";
|
$sql = "SELECT count(a.rowid) as nb";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
||||||
$sql.= " WHERE a.statut > 0";
|
$sql.= " WHERE a.statut > 0";
|
||||||
$sql.= " AND a.entity IN (".getEntity('adherent', 1).")";
|
$sql.= " AND a.entity IN (".getEntity('adherent').")";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -1818,7 +1818,7 @@ class Adherent extends CommonObject
|
|||||||
$sql = "SELECT a.rowid, a.datefin, a.statut";
|
$sql = "SELECT a.rowid, a.datefin, a.statut";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
|
||||||
$sql.= " WHERE a.statut = 1";
|
$sql.= " WHERE a.statut = 1";
|
||||||
$sql.= " AND a.entity IN (".getEntity('adherent', 1).")";
|
$sql.= " AND a.entity IN (".getEntity('adherent').")";
|
||||||
$sql.= " AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";
|
$sql.= " AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class AdherentStats extends Stats
|
|||||||
$this->field='subscription';
|
$this->field='subscription';
|
||||||
|
|
||||||
$this->where.= " m.statut != 0";
|
$this->where.= " m.statut != 0";
|
||||||
$this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent', 1).")";
|
$this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")";
|
||||||
//if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
//if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if($this->memberid)
|
if($this->memberid)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -100,7 +100,7 @@ class Members extends DolibarrApi
|
|||||||
|
|
||||||
$sql = "SELECT t.rowid";
|
$sql = "SELECT t.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as t";
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('adherent', 1).')';
|
$sql.= ' WHERE t.entity IN ('.getEntity('adherent').')';
|
||||||
if (!empty($typeid))
|
if (!empty($typeid))
|
||||||
{
|
{
|
||||||
$sql.= ' AND t.fk_adherent_type='.$typeid;
|
$sql.= ' AND t.fk_adherent_type='.$typeid;
|
||||||
|
|||||||
@ -97,7 +97,7 @@ class MembersTypes extends DolibarrApi
|
|||||||
|
|
||||||
$sql = "SELECT t.rowid";
|
$sql = "SELECT t.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('adherent', 1).')';
|
$sql.= ' WHERE t.entity IN ('.getEntity('adherent').')';
|
||||||
|
|
||||||
// Add sql filters
|
// Add sql filters
|
||||||
if ($sqlfilters)
|
if ($sqlfilters)
|
||||||
|
|||||||
@ -210,7 +210,7 @@ if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid);
|
|||||||
if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
|
if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
|
||||||
if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
|
if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
|
||||||
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
|
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
|
||||||
$sql.= " AND d.entity IN (".getEntity('adherent', 1).")";
|
$sql.= " AND d.entity IN (".getEntity('adherent').")";
|
||||||
if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall);
|
if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall);
|
||||||
if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type);
|
if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type);
|
||||||
if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
|
if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
|
||||||
|
|||||||
@ -123,7 +123,7 @@ $sql.= " b.fk_account";
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
|
||||||
$sql.= " WHERE d.rowid = c.fk_adherent";
|
$sql.= " WHERE d.rowid = c.fk_adherent";
|
||||||
$sql.= " AND d.entity IN (".getEntity('adherent', 1).")";
|
$sql.= " AND d.entity IN (".getEntity('adherent').")";
|
||||||
if (isset($date_select) && $date_select != '')
|
if (isset($date_select) && $date_select != '')
|
||||||
{
|
{
|
||||||
$sql.= " AND c.dateadh LIKE '".$date_select."%'";
|
$sql.= " AND c.dateadh LIKE '".$date_select."%'";
|
||||||
|
|||||||
@ -235,7 +235,7 @@ $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,";
|
|||||||
$sql.= " bd.rowid as boxid";
|
$sql.= " bd.rowid as boxid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
|
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
|
||||||
$sql.= " WHERE b.box_id = bd.rowid";
|
$sql.= " WHERE b.box_id = bd.rowid";
|
||||||
$sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
$sql.= " AND b.entity IN (0,".$conf->entity.")";
|
||||||
$sql.= " AND b.fk_user=0";
|
$sql.= " AND b.fk_user=0";
|
||||||
$sql.= " ORDER by b.position, b.box_order";
|
$sql.= " ORDER by b.position, b.box_order";
|
||||||
|
|
||||||
|
|||||||
@ -148,7 +148,6 @@ print "</tr>\n";
|
|||||||
|
|
||||||
foreach ($list as $key)
|
foreach ($list as $key)
|
||||||
{
|
{
|
||||||
|
|
||||||
print '<tr class="oddeven value">';
|
print '<tr class="oddeven value">';
|
||||||
|
|
||||||
// Param
|
// Param
|
||||||
|
|||||||
@ -189,7 +189,7 @@ $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX
|
|||||||
$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
|
$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
|
||||||
$tabsql[23]= "SELECT t.rowid as rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
|
$tabsql[23]= "SELECT t.rowid as rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
|
||||||
$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
|
$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
|
||||||
//$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template',1).")";
|
//$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")";
|
||||||
$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
|
$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
|
||||||
$tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm";
|
$tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm";
|
||||||
$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
|
$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
|
||||||
|
|||||||
@ -616,7 +616,7 @@ if (! empty($conf->banque->enabled))
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
|
||||||
$sql.= " WHERE clos = 0";
|
$sql.= " WHERE clos = 0";
|
||||||
$sql.= " AND courant = 1";
|
$sql.= " AND courant = 1";
|
||||||
$sql.= " AND entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND entity IN (".getEntity('bank_account').")";
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -661,7 +661,7 @@ $sql = "SELECT rowid, label";
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
|
||||||
$sql.= " WHERE clos = 0";
|
$sql.= " WHERE clos = 0";
|
||||||
$sql.= " AND courant = 1";
|
$sql.= " AND courant = 1";
|
||||||
$sql.= " AND entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND entity IN (".getEntity('bank_account').")";
|
||||||
$var=True;
|
$var=True;
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@ -547,7 +547,6 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
|
|||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
// print products on fichinter
|
// print products on fichinter
|
||||||
$var=! $var;
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="set_FICHINTER_PRINT_PRODUCTS">';
|
print '<input type="hidden" name="action" value="set_FICHINTER_PRINT_PRODUCTS">';
|
||||||
|
|||||||
@ -80,7 +80,7 @@ $tabname[25]= MAIN_DB_PREFIX."c_email_templates";
|
|||||||
|
|
||||||
// Requests to extract data
|
// Requests to extract data
|
||||||
$tabsql=array();
|
$tabsql=array();
|
||||||
$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template',1).")";
|
$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")";
|
||||||
|
|
||||||
// Criteria to sort dictionaries
|
// Criteria to sort dictionaries
|
||||||
$tabsqlsort=array();
|
$tabsqlsort=array();
|
||||||
|
|||||||
@ -131,7 +131,7 @@ print '<table class="noborder" width="100%">';
|
|||||||
$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
|
$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
|
||||||
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
$sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous"
|
||||||
$sql.= " AND entity IN (".(! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
|
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled
|
||||||
$sql.= " ORDER BY r.module, r.id";
|
$sql.= " ORDER BY r.module, r.id";
|
||||||
|
|
||||||
|
|||||||
@ -165,7 +165,7 @@ $sql.= " e.fk_user, e.description,";
|
|||||||
$sql.= " u.login";
|
$sql.= " u.login";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."events as e";
|
$sql.= " FROM ".MAIN_DB_PREFIX."events as e";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user";
|
||||||
$sql.= " WHERE e.entity IN (".getEntity('event', 1).")";
|
$sql.= " WHERE e.entity IN (".getEntity('event').")";
|
||||||
if ($date_start > 0) $sql.= " AND e.dateevent >= '".$db->idate($date_start)."'";
|
if ($date_start > 0) $sql.= " AND e.dateevent >= '".$db->idate($date_start)."'";
|
||||||
if ($date_end > 0) $sql.= " AND e.dateevent <= '".$db->idate($date_end)."'";
|
if ($date_end > 0) $sql.= " AND e.dateevent <= '".$db->idate($date_end)."'";
|
||||||
if ($search_code) { $usefilter++; $sql.=natural_search("e.type", $search_code, 0); }
|
if ($search_code) { $usefilter++; $sql.=natural_search("e.type", $search_code, 0); }
|
||||||
|
|||||||
@ -48,7 +48,7 @@ if (empty($phone))
|
|||||||
|
|
||||||
$sql = "SELECT s.nom as name FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql = "SELECT s.nom as name FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
|
||||||
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
|
$sql.= " WHERE s.entity IN (".getEntity('societe').")";
|
||||||
$sql.= " AND (s.phone='".$db->escape($phone)."'";
|
$sql.= " AND (s.phone='".$db->escape($phone)."'";
|
||||||
$sql.= " OR sp.phone='".$db->escape($phone)."'";
|
$sql.= " OR sp.phone='".$db->escape($phone)."'";
|
||||||
$sql.= " OR sp.phone_perso='".$db->escape($phone)."'";
|
$sql.= " OR sp.phone_perso='".$db->escape($phone)."'";
|
||||||
|
|||||||
@ -117,7 +117,7 @@ llxHeader();
|
|||||||
|
|
||||||
$sql = "SELECT s.nom as name FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql = "SELECT s.nom as name FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
|
||||||
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
|
$sql.= " WHERE s.entity IN (".getEntity('societe').")";
|
||||||
$sql.= " AND (s.phone='".$db->escape($called)."'";
|
$sql.= " AND (s.phone='".$db->escape($called)."'";
|
||||||
$sql.= " OR sp.phone='".$db->escape($called)."'";
|
$sql.= " OR sp.phone='".$db->escape($called)."'";
|
||||||
$sql.= " OR sp.phone_perso='".$db->escape($called)."'";
|
$sql.= " OR sp.phone_perso='".$db->escape($called)."'";
|
||||||
|
|||||||
@ -63,7 +63,7 @@ function printBookmarksList($aDb, $aLangs)
|
|||||||
{
|
{
|
||||||
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
|
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
|
||||||
$sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
|
$sql.= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
|
||||||
$sql.= " AND entity IN (".getEntity('bookmarks',1).")";
|
$sql.= " AND entity IN (".getEntity('bookmarks').")";
|
||||||
$sql.= " ORDER BY position";
|
$sql.= " ORDER BY position";
|
||||||
if ($resql = $db->query($sql) )
|
if ($resql = $db->query($sql) )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -44,7 +44,7 @@ if ( GETPOST('filtre') ) {
|
|||||||
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
|
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'";
|
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'";
|
||||||
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE p.entity IN (".getEntity('product').")";
|
||||||
$sql.= " AND p.tosell = 1";
|
$sql.= " AND p.tosell = 1";
|
||||||
if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0";
|
if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0";
|
||||||
$sql.= " AND (p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'";
|
$sql.= " AND (p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'";
|
||||||
@ -96,7 +96,7 @@ if ( GETPOST('filtre') ) {
|
|||||||
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
|
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'";
|
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'";
|
||||||
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE p.entity IN (".getEntity('product').")";
|
||||||
$sql.= " AND p.tosell = 1";
|
$sql.= " AND p.tosell = 1";
|
||||||
if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0";
|
if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0";
|
||||||
$sql.= " ORDER BY p.label";
|
$sql.= " ORDER BY p.label";
|
||||||
|
|||||||
@ -50,7 +50,7 @@ if (dol_strlen($search) >= 0) // If search criteria is on char length at least
|
|||||||
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
|
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'";
|
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'";
|
||||||
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE p.entity IN (".getEntity('product').")";
|
||||||
$sql.= " AND p.tosell = 1";
|
$sql.= " AND p.tosell = 1";
|
||||||
$sql.= " AND p.fk_product_type = 0";
|
$sql.= " AND p.fk_product_type = 0";
|
||||||
// Add criteria on ref/label
|
// Add criteria on ref/label
|
||||||
|
|||||||
@ -43,7 +43,7 @@ switch($action)
|
|||||||
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
|
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot;
|
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot;
|
||||||
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE p.entity IN (".getEntity('product').")";
|
||||||
|
|
||||||
// Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ...
|
// Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ...
|
||||||
if ( $_POST['hdnSource'] == 'LISTE' )
|
if ( $_POST['hdnSource'] == 'LISTE' )
|
||||||
|
|||||||
@ -114,7 +114,7 @@ class Categories extends DolibarrApi
|
|||||||
|
|
||||||
$sql = "SELECT t.rowid";
|
$sql = "SELECT t.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as t";
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('category', 1).')';
|
$sql.= ' WHERE t.entity IN ('.getEntity('category').')';
|
||||||
if (!empty($type))
|
if (!empty($type))
|
||||||
{
|
{
|
||||||
$sql.= ' AND t.type='.array_search($type,Categories::$TYPES);
|
$sql.= ' AND t.type='.array_search($type,Categories::$TYPES);
|
||||||
@ -205,7 +205,7 @@ class Categories extends DolibarrApi
|
|||||||
$sql = "SELECT s.rowid";
|
$sql = "SELECT s.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
||||||
$sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
|
$sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
|
||||||
$sql.= ' WHERE s.entity IN ('.getEntity('category', 1).')';
|
$sql.= ' WHERE s.entity IN ('.getEntity('category').')';
|
||||||
$sql.= ' AND s.type='.array_search($type,Categories::$TYPES);
|
$sql.= ' AND s.type='.array_search($type,Categories::$TYPES);
|
||||||
$sql.= ' AND s.rowid = sub.fk_categorie';
|
$sql.= ' AND s.rowid = sub.fk_categorie';
|
||||||
$sql.= ' AND sub.'.$subcol_name.' = '.$item;
|
$sql.= ' AND sub.'.$subcol_name.' = '.$item;
|
||||||
|
|||||||
@ -121,7 +121,7 @@ class CategoryApi extends DolibarrApi
|
|||||||
|
|
||||||
$sql = "SELECT s.rowid";
|
$sql = "SELECT s.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
||||||
$sql.= ' WHERE s.entity IN ('.getEntity('category', 1).')';
|
$sql.= ' WHERE s.entity IN ('.getEntity('category').')';
|
||||||
$sql.= ' AND s.type='.array_search($type,CategoryApi::$TYPES);
|
$sql.= ' AND s.type='.array_search($type,CategoryApi::$TYPES);
|
||||||
|
|
||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
@ -201,7 +201,7 @@ class CategoryApi extends DolibarrApi
|
|||||||
$sql = "SELECT s.rowid";
|
$sql = "SELECT s.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
||||||
$sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
|
$sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
|
||||||
$sql.= ' WHERE s.entity IN ('.getEntity('category', 1).')';
|
$sql.= ' WHERE s.entity IN ('.getEntity('category').')';
|
||||||
$sql.= ' AND s.type='.array_search($type,CategoryApi::$TYPES);
|
$sql.= ' AND s.type='.array_search($type,CategoryApi::$TYPES);
|
||||||
$sql.= ' AND s.rowid = sub.fk_categorie';
|
$sql.= ' AND s.rowid = sub.fk_categorie';
|
||||||
$sql.= ' AND sub.'.$subcol_name.' = '.$item;
|
$sql.= ' AND sub.'.$subcol_name.' = '.$item;
|
||||||
|
|||||||
@ -195,7 +195,7 @@ class Categorie extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category',1).")";
|
$sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")";
|
||||||
if ($type) $sql.= " AND type = '".$this->db->escape($type)."'";
|
if ($type) $sql.= " AND type = '".$this->db->escape($type)."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,7 +903,7 @@ class Categorie extends CommonObject
|
|||||||
$sql = "SELECT fk_parent as id_parent, rowid as id_son";
|
$sql = "SELECT fk_parent as id_parent, rowid as id_son";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
|
||||||
$sql.= " WHERE fk_parent != 0";
|
$sql.= " WHERE fk_parent != 0";
|
||||||
$sql.= " AND entity IN (".getEntity('category',1).")";
|
$sql.= " AND entity IN (".getEntity('category').")";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
|
dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -1094,7 +1094,7 @@ class Categorie extends CommonObject
|
|||||||
function get_all_categories($type=null, $parent=false)
|
function get_all_categories($type=null, $parent=false)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
|
||||||
$sql.= " WHERE entity IN (".getEntity('category',1).")";
|
$sql.= " WHERE entity IN (".getEntity('category').")";
|
||||||
if (! is_null($type))
|
if (! is_null($type))
|
||||||
$sql.= " AND type = ".$type;
|
$sql.= " AND type = ".$type;
|
||||||
if ($parent)
|
if ($parent)
|
||||||
@ -1129,7 +1129,7 @@ class Categorie extends CommonObject
|
|||||||
{
|
{
|
||||||
$sql = "SELECT count(rowid)";
|
$sql = "SELECT count(rowid)";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
|
||||||
$sql.= " WHERE entity IN (".getEntity('category',1).")";
|
$sql.= " WHERE entity IN (".getEntity('category').")";
|
||||||
$res = $this->db->query($sql);
|
$res = $this->db->query($sql);
|
||||||
if ($res)
|
if ($res)
|
||||||
{
|
{
|
||||||
@ -1155,7 +1155,7 @@ class Categorie extends CommonObject
|
|||||||
*/
|
*/
|
||||||
$sql = "SELECT c.rowid";
|
$sql = "SELECT c.rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c ";
|
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c ";
|
||||||
$sql.= " WHERE c.entity IN (".getEntity('category',1).")";
|
$sql.= " WHERE c.entity IN (".getEntity('category').")";
|
||||||
$sql.= " AND c.type = ".$this->type;
|
$sql.= " AND c.type = ".$this->type;
|
||||||
$sql.= " AND c.fk_parent = ".$this->fk_parent;
|
$sql.= " AND c.fk_parent = ".$this->fk_parent;
|
||||||
$sql.= " AND c.label = '".$this->db->escape($this->label)."'";
|
$sql.= " AND c.label = '".$this->db->escape($this->label)."'";
|
||||||
|
|||||||
@ -870,7 +870,7 @@ class ActionComm extends CommonObject
|
|||||||
|
|
||||||
$sql = "SELECT a.id";
|
$sql = "SELECT a.id";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||||
$sql.= " WHERE a.entity IN (".getEntity('agenda', 1).")";
|
$sql.= " WHERE a.entity IN (".getEntity('agenda').")";
|
||||||
if (! empty($socid)) $sql.= " AND a.fk_soc = ".$socid;
|
if (! empty($socid)) $sql.= " AND a.fk_soc = ".$socid;
|
||||||
if (! empty($elementtype))
|
if (! empty($elementtype))
|
||||||
{
|
{
|
||||||
@ -921,7 +921,7 @@ class ActionComm extends CommonObject
|
|||||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
|
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
|
||||||
$sql.= " WHERE a.percent >= 0 AND a.percent < 100";
|
$sql.= " WHERE a.percent >= 0 AND a.percent < 100";
|
||||||
$sql.= " AND a.entity IN (".getEntity('agenda', 1).")";
|
$sql.= " AND a.entity IN (".getEntity('agenda').")";
|
||||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
|
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
|
||||||
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
|
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
|
||||||
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
|
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
|
||||||
@ -1281,7 +1281,7 @@ class ActionComm extends CommonObject
|
|||||||
// We must filter on assignement table
|
// We must filter on assignement table
|
||||||
if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
if ($filters['logint'] || $filters['login']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
||||||
$sql.= " WHERE a.fk_action=c.id";
|
$sql.= " WHERE a.fk_action=c.id";
|
||||||
$sql.= " AND a.entity IN (".getEntity('agenda', 1).")";
|
$sql.= " AND a.entity IN (".getEntity('agenda').")";
|
||||||
foreach ($filters as $key => $value)
|
foreach ($filters as $key => $value)
|
||||||
{
|
{
|
||||||
if ($key == 'notolderthan' && $value != '') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'";
|
if ($key == 'notolderthan' && $value != '') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'";
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class AgendaEvents extends DolibarrApi
|
|||||||
|
|
||||||
$sql = "SELECT t.id as rowid";
|
$sql = "SELECT t.id as rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t";
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('agenda', 1).')';
|
$sql.= ' WHERE t.entity IN ('.getEntity('agenda').')';
|
||||||
if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")";
|
if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")";
|
||||||
if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid;
|
if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid;
|
||||||
// Insert sale filter
|
// Insert sale filter
|
||||||
|
|||||||
@ -456,7 +456,7 @@ if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
|
|||||||
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
||||||
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
||||||
$sql.= ' WHERE a.fk_action = ca.id';
|
$sql.= ' WHERE a.fk_action = ca.id';
|
||||||
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
|
$sql.= ' AND a.entity IN ('.getEntity('agenda').')';
|
||||||
// Condition on actioncode
|
// Condition on actioncode
|
||||||
if (! empty($actioncode))
|
if (! empty($actioncode))
|
||||||
{
|
{
|
||||||
@ -648,7 +648,7 @@ if ($showbirthday)
|
|||||||
$sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
|
$sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
|
||||||
$sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))';
|
$sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))';
|
||||||
$sql.= " AND sp.entity IN (".getEntity('societe', 1).")";
|
$sql.= " AND sp.entity IN (".getEntity('societe').")";
|
||||||
if ($action == 'show_day')
|
if ($action == 'show_day')
|
||||||
{
|
{
|
||||||
$sql.= ' AND MONTH(birthday) = '.$month;
|
$sql.= ' AND MONTH(birthday) = '.$month;
|
||||||
|
|||||||
@ -197,7 +197,7 @@ if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
|
|||||||
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
||||||
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
||||||
$sql.= " WHERE c.id = a.fk_action";
|
$sql.= " WHERE c.id = a.fk_action";
|
||||||
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
|
$sql.= ' AND a.entity IN ('.getEntity('agenda').')';
|
||||||
// Condition on actioncode
|
// Condition on actioncode
|
||||||
if (! empty($actioncode))
|
if (! empty($actioncode))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -364,7 +364,7 @@ if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
|
|||||||
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
||||||
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
||||||
$sql.= ' WHERE a.fk_action = ca.id';
|
$sql.= ' WHERE a.fk_action = ca.id';
|
||||||
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
|
$sql.= ' AND a.entity IN ('.getEntity('agenda').')';
|
||||||
// Condition on actioncode
|
// Condition on actioncode
|
||||||
if (! empty($actioncode))
|
if (! empty($actioncode))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -371,7 +371,7 @@ if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r";
|
|||||||
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
|
||||||
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
|
||||||
$sql.= ' WHERE a.fk_action = ca.id';
|
$sql.= ' WHERE a.fk_action = ca.id';
|
||||||
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
|
$sql.= ' AND a.entity IN ('.getEntity('agenda').')';
|
||||||
// Condition on actioncode
|
// Condition on actioncode
|
||||||
if (! empty($actioncode))
|
if (! empty($actioncode))
|
||||||
{
|
{
|
||||||
@ -661,7 +661,7 @@ else
|
|||||||
$sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
|
$sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||||
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user";
|
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user";
|
||||||
$sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user',1).")";
|
$sql.= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")";
|
||||||
if ($usergroup > 0) $sql.= " AND ug.fk_usergroup = ".$usergroup;
|
if ($usergroup > 0) $sql.= " AND ug.fk_usergroup = ".$usergroup;
|
||||||
//print $sql;
|
//print $sql;
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
|
|||||||
@ -80,7 +80,7 @@ $sql.= " date_format(a.datep, '%Y') as year";
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a,";
|
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."user as u";
|
$sql.= " ".MAIN_DB_PREFIX."user as u";
|
||||||
$sql.= " WHERE a.fk_user_author = u.rowid";
|
$sql.= " WHERE a.fk_user_author = u.rowid";
|
||||||
$sql.= ' AND a.entity IN ('.getEntity('agenda', 1).')';
|
$sql.= ' AND a.entity IN ('.getEntity('agenda').')';
|
||||||
//$sql.= " AND percent = 100";
|
//$sql.= " AND percent = 100";
|
||||||
$sql.= " GROUP BY year, month, df";
|
$sql.= " GROUP BY year, month, df";
|
||||||
$sql.= " ORDER BY year DESC, month DESC, df DESC";
|
$sql.= " ORDER BY year DESC, month DESC, df DESC";
|
||||||
|
|||||||
@ -757,7 +757,7 @@ if ($id > 0)
|
|||||||
$sql.= ', s.rowid as socid';
|
$sql.= ', s.rowid as socid';
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e";
|
||||||
$sql.= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id;
|
$sql.= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id;
|
||||||
$sql.= " AND e.entity IN (".getEntity('expedition', 1).")";
|
$sql.= " AND e.entity IN (".getEntity('expedition').")";
|
||||||
$sql.= ' GROUP BY e.rowid';
|
$sql.= ' GROUP BY e.rowid';
|
||||||
$sql.= ', e.ref';
|
$sql.= ', e.ref';
|
||||||
$sql.= ', e.date_creation';
|
$sql.= ', e.date_creation';
|
||||||
|
|||||||
@ -78,7 +78,7 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql .= " ".MAIN_DB_PREF
|
|||||||
$sql.= " ".MAIN_DB_PREFIX."socpeople as p";
|
$sql.= " ".MAIN_DB_PREFIX."socpeople as p";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
|
||||||
$sql.= " WHERE s.fk_stcomm = st.id";
|
$sql.= " WHERE s.fk_stcomm = st.id";
|
||||||
$sql.= " AND p.entity IN (".getEntity('societe', 1).")";
|
$sql.= " AND p.entity IN (".getEntity('societe').")";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($type == "c") $sql.= " AND s.client IN (1, 3)";
|
if ($type == "c") $sql.= " AND s.client IN (1, 3)";
|
||||||
if ($type == "p") $sql.= " AND s.client IN (2, 3)";
|
if ($type == "p") $sql.= " AND s.client IN (2, 3)";
|
||||||
|
|||||||
@ -146,7 +146,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
|
|||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE p.fk_statut = 0";
|
$sql.= " WHERE p.fk_statut = 0";
|
||||||
$sql.= " AND p.fk_soc = s.rowid";
|
$sql.= " AND p.fk_soc = s.rowid";
|
||||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND p.entity IN (".getEntity('propal').")";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos
|
|||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE p.fk_statut = 0";
|
$sql.= " WHERE p.fk_statut = 0";
|
||||||
$sql.= " AND p.fk_soc = s.rowid";
|
$sql.= " AND p.fk_soc = s.rowid";
|
||||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND p.entity IN (".getEntity('propal').")";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
|
|||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.fk_statut = 0";
|
$sql.= " AND c.fk_statut = 0";
|
||||||
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('commande').")";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande
|
|||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE cf.fk_soc = s.rowid";
|
$sql.= " WHERE cf.fk_soc = s.rowid";
|
||||||
$sql.= " AND cf.fk_statut = 0";
|
$sql.= " AND cf.fk_statut = 0";
|
||||||
$sql.= " AND cf.entity IN (".getEntity('supplier_order', 1).")";
|
$sql.= " AND cf.entity IN (".getEntity('supplier_order').")";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND cf.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND cf.fk_soc = ".$socid;
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."product as p";
|
$sql.= ", ".MAIN_DB_PREFIX."product as p";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('contract', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('contract').")";
|
||||||
$sql.= " AND c.fk_product = p.rowid";
|
$sql.= " AND c.fk_product = p.rowid";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||||
@ -669,7 +669,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
|
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE p.fk_soc = s.rowid";
|
$sql.= " WHERE p.fk_soc = s.rowid";
|
||||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND p.entity IN (".getEntity('propal').")";
|
||||||
$sql.= " AND p.fk_statut = 1";
|
$sql.= " AND p.fk_statut = 1";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||||
@ -766,7 +766,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
|
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('commande').")";
|
||||||
$sql.= " AND c.fk_statut = 1";
|
$sql.= " AND c.fk_statut = 1";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||||
|
|||||||
@ -466,7 +466,7 @@ class AdvanceTargetingMailing extends CommonObject
|
|||||||
|
|
||||||
$sqlwhere=array();
|
$sqlwhere=array();
|
||||||
|
|
||||||
$sqlwhere[]= 't.entity IN ('.getEntity('societe',1).')';
|
$sqlwhere[]= 't.entity IN ('.getEntity('societe').')';
|
||||||
|
|
||||||
if (count($arrayquery)>0) {
|
if (count($arrayquery)>0) {
|
||||||
|
|
||||||
@ -625,7 +625,7 @@ class AdvanceTargetingMailing extends CommonObject
|
|||||||
|
|
||||||
$sqlwhere=array();
|
$sqlwhere=array();
|
||||||
|
|
||||||
$sqlwhere[]= 't.entity IN ('.getEntity('socpeople',1).')';
|
$sqlwhere[]= 't.entity IN ('.getEntity('socpeople').')';
|
||||||
|
|
||||||
if (count($arrayquery)>0) {
|
if (count($arrayquery)>0) {
|
||||||
|
|
||||||
|
|||||||
@ -1601,7 +1601,7 @@ if ($action == 'create')
|
|||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "propal p";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "propal p";
|
||||||
$sql .= ", " . MAIN_DB_PREFIX . "societe s";
|
$sql .= ", " . MAIN_DB_PREFIX . "societe s";
|
||||||
$sql .= " WHERE s.rowid = p.fk_soc";
|
$sql .= " WHERE s.rowid = p.fk_soc";
|
||||||
$sql .= " AND p.entity IN (".getEntity('propal', 1).")";
|
$sql .= " AND p.entity IN (".getEntity('propal').")";
|
||||||
$sql .= " AND p.fk_statut <> 0";
|
$sql .= " AND p.fk_statut <> 0";
|
||||||
$sql .= " ORDER BY Id";
|
$sql .= " ORDER BY Id";
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class Proposals extends DolibarrApi
|
|||||||
|
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||||
|
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('propal', 1).')';
|
$sql.= ' WHERE t.entity IN ('.getEntity('propal').')';
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
||||||
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
|
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
|
||||||
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||||
|
|||||||
@ -1276,7 +1276,7 @@ class Propal extends CommonObject
|
|||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';
|
||||||
$sql.= " WHERE p.fk_statut = c.id";
|
$sql.= " WHERE p.fk_statut = c.id";
|
||||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND p.entity IN (".getEntity('propal').")";
|
||||||
if ($ref) $sql.= " AND p.ref='".$ref."'";
|
if ($ref) $sql.= " AND p.ref='".$ref."'";
|
||||||
else $sql.= " AND p.rowid=".$rowid;
|
else $sql.= " AND p.rowid=".$rowid;
|
||||||
|
|
||||||
@ -2499,7 +2499,7 @@ class Propal extends CommonObject
|
|||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " WHERE p.entity IN (".getEntity('propal').")";
|
||||||
$sql.= " AND p.fk_soc = s.rowid";
|
$sql.= " AND p.fk_soc = s.rowid";
|
||||||
$sql.= " AND p.fk_statut = c.id";
|
$sql.= " AND p.fk_statut = c.id";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) //restriction
|
if (! $user->rights->societe->client->voir && ! $socid) //restriction
|
||||||
@ -3025,7 +3025,7 @@ class Propal extends CommonObject
|
|||||||
$sql.= " WHERE sc.fk_user = " .$user->id;
|
$sql.= " WHERE sc.fk_user = " .$user->id;
|
||||||
$clause = " AND";
|
$clause = " AND";
|
||||||
}
|
}
|
||||||
$sql.= $clause." p.entity IN (".getEntity('propal', 1).")";
|
$sql.= $clause." p.entity IN (".getEntity('propal').")";
|
||||||
if ($mode == 'opened') $sql.= " AND p.fk_statut = ".self::STATUS_VALIDATED;
|
if ($mode == 'opened') $sql.= " AND p.fk_statut = ".self::STATUS_VALIDATED;
|
||||||
if ($mode == 'signed') $sql.= " AND p.fk_statut = ".self::STATUS_SIGNED;
|
if ($mode == 'signed') $sql.= " AND p.fk_statut = ".self::STATUS_SIGNED;
|
||||||
if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id;
|
if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id;
|
||||||
@ -3096,7 +3096,7 @@ class Propal extends CommonObject
|
|||||||
$prodids = array();
|
$prodids = array();
|
||||||
$sql = "SELECT rowid";
|
$sql = "SELECT rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||||
$sql.= " WHERE entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE entity IN (".getEntity('product').")";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -3194,7 +3194,7 @@ class Propal extends CommonObject
|
|||||||
$sql.= " WHERE sc.fk_user = " .$user->id;
|
$sql.= " WHERE sc.fk_user = " .$user->id;
|
||||||
$clause = "AND";
|
$clause = "AND";
|
||||||
}
|
}
|
||||||
$sql.= " ".$clause." p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " ".$clause." p.entity IN (".getEntity('propal').")";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@ -86,7 +86,7 @@ class PropaleStats extends Stats
|
|||||||
$this->where.= " p.fk_statut > 0"; // Validated, accepted, refused and closed
|
$this->where.= " p.fk_statut > 0"; // Validated, accepted, refused and closed
|
||||||
}
|
}
|
||||||
//$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity;
|
//$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity;
|
||||||
$this->where.= " AND p.entity IN (".getEntity('propal', 1).")";
|
$this->where.= " AND p.entity IN (".getEntity('propal').")";
|
||||||
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if($this->socid)
|
if($this->socid)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -81,7 +81,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
|
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE p.fk_soc = s.rowid";
|
$sql.= " WHERE p.fk_soc = s.rowid";
|
||||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND p.entity IN (".getEntity('propal').")";
|
||||||
if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id;
|
if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
$sql.= " AND p.fk_statut IN (0,1,2,3,4)";
|
$sql.= " AND p.fk_statut IN (0,1,2,3,4)";
|
||||||
@ -157,7 +157,7 @@ if (! empty($conf->propal->enabled))
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('propal').")";
|
||||||
$sql.= " AND c.fk_statut = 0";
|
$sql.= " AND c.fk_statut = 0";
|
||||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
@ -215,7 +215,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."propal as c";
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('propal').")";
|
||||||
//$sql.= " AND c.fk_statut > 2";
|
//$sql.= " AND c.fk_statut > 2";
|
||||||
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
|
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
@ -294,7 +294,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
|
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE p.fk_soc = s.rowid";
|
$sql.= " WHERE p.fk_soc = s.rowid";
|
||||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND p.entity IN (".getEntity('propal').")";
|
||||||
$sql.= " AND p.fk_statut = 1";
|
$sql.= " AND p.fk_statut = 1";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||||
|
|||||||
@ -269,7 +269,7 @@ if ($search_user > 0)
|
|||||||
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||||
}
|
}
|
||||||
$sql.= ' WHERE p.fk_soc = s.rowid';
|
$sql.= ' WHERE p.fk_soc = s.rowid';
|
||||||
$sql.= ' AND p.entity IN ('.getEntity('propal', 1).')';
|
$sql.= ' AND p.entity IN ('.getEntity('propal').')';
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) //restriction
|
if (! $user->rights->societe->client->voir && ! $socid) //restriction
|
||||||
{
|
{
|
||||||
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
$sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
|
|||||||
@ -120,7 +120,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
|
|||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE p.fk_statut = 0";
|
$sql.= " WHERE p.fk_statut = 0";
|
||||||
$sql.= " AND p.fk_soc = s.rowid";
|
$sql.= " AND p.fk_soc = s.rowid";
|
||||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND p.entity IN (".getEntity('propal').")";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
@ -183,7 +183,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
|
|||||||
$sql.= " WHERE p.fk_soc = s.rowid";
|
$sql.= " WHERE p.fk_soc = s.rowid";
|
||||||
$sql.= " AND p.fk_statut = c.id";
|
$sql.= " AND p.fk_statut = c.id";
|
||||||
$sql.= " AND p.fk_statut = 1";
|
$sql.= " AND p.fk_statut = 1";
|
||||||
$sql.= " AND p.entity IN (".getEntity('propal', 1).")";
|
$sql.= " AND p.entity IN (".getEntity('propal').")";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||||
$sql.= " ORDER BY p.rowid DESC";
|
$sql.= " ORDER BY p.rowid DESC";
|
||||||
|
|||||||
@ -128,7 +128,7 @@ class CommandeApi extends DolibarrApi
|
|||||||
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
|
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
|
||||||
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
|
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
|
||||||
|
|
||||||
$sql.= ' WHERE s.entity IN ('.getEntity('commande', 1).')';
|
$sql.= ' WHERE s.entity IN ('.getEntity('commande').')';
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
|
||||||
if ($socid) $sql.= " AND s.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND s.fk_soc = ".$socid;
|
||||||
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||||
|
|||||||
@ -115,7 +115,7 @@ class Orders extends DolibarrApi
|
|||||||
|
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||||
|
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('commande', 1).')';
|
$sql.= ' WHERE t.entity IN ('.getEntity('commande').')';
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
||||||
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
|
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
|
||||||
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||||
|
|||||||
@ -1564,7 +1564,7 @@ class Commande extends CommonOrder
|
|||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)';
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)';
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
|
||||||
$sql.= " WHERE c.entity IN (".getEntity('commande', 1).")";
|
$sql.= " WHERE c.entity IN (".getEntity('commande').")";
|
||||||
if ($id) $sql.= " AND c.rowid=".$id;
|
if ($id) $sql.= " AND c.rowid=".$id;
|
||||||
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
|
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
|
||||||
if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
|
if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
|
||||||
@ -2369,7 +2369,7 @@ class Commande extends CommonOrder
|
|||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.entity IN (".getEntity('commande', 1).")";
|
$sql.= " WHERE c.entity IN (".getEntity('commande').")";
|
||||||
$sql.= " AND c.fk_soc = s.rowid";
|
$sql.= " AND c.fk_soc = s.rowid";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) //restriction
|
if (! $user->rights->societe->client->voir && ! $socid) //restriction
|
||||||
{
|
{
|
||||||
@ -3222,7 +3222,7 @@ class Commande extends CommonOrder
|
|||||||
$sql.= " WHERE sc.fk_user = " .$user->id;
|
$sql.= " WHERE sc.fk_user = " .$user->id;
|
||||||
$clause = " AND";
|
$clause = " AND";
|
||||||
}
|
}
|
||||||
$sql.= $clause." c.entity IN (".getEntity('commande', 1).")";
|
$sql.= $clause." c.entity IN (".getEntity('commande').")";
|
||||||
//$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
|
//$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
|
||||||
$sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_ACCEPTED.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
|
$sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_ACCEPTED.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
|
||||||
if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
|
if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
|
||||||
@ -3506,7 +3506,7 @@ class Commande extends CommonOrder
|
|||||||
$prodids = array();
|
$prodids = array();
|
||||||
$sql = "SELECT rowid";
|
$sql = "SELECT rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||||
$sql.= " WHERE entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE entity IN (".getEntity('product').")";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -3598,7 +3598,7 @@ class Commande extends CommonOrder
|
|||||||
$sql.= " WHERE sc.fk_user = " .$user->id;
|
$sql.= " WHERE sc.fk_user = " .$user->id;
|
||||||
$clause = "AND";
|
$clause = "AND";
|
||||||
}
|
}
|
||||||
$sql.= " ".$clause." co.entity IN (".getEntity('commande', 1).")";
|
$sql.= " ".$clause." co.entity IN (".getEntity('commande').")";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@ -81,7 +81,7 @@ class CommandeStats extends Stats
|
|||||||
$this->where.= " c.fk_statut > 2"; // Only approved & ordered
|
$this->where.= " c.fk_statut > 2"; // Only approved & ordered
|
||||||
}
|
}
|
||||||
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
||||||
$this->where.= ' AND c.entity IN ('.getEntity('commande', 1).')';
|
$this->where.= ' AND c.entity IN ('.getEntity('commande').')';
|
||||||
|
|
||||||
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($this->socid)
|
if ($this->socid)
|
||||||
|
|||||||
@ -75,7 +75,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid";
|
$sql.= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid";
|
||||||
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
|
$sql.= " AND s.entity IN (".getEntity('societe').")";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if (dol_strlen($stcomm))
|
if (dol_strlen($stcomm))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -85,7 +85,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
|
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('societe', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('societe').")";
|
||||||
if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
|
if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
$sql.= " GROUP BY c.fk_statut, c.facture";
|
$sql.= " GROUP BY c.fk_statut, c.facture";
|
||||||
@ -177,7 +177,7 @@ if (! empty($conf->commande->enabled))
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('commande').")";
|
||||||
$sql.= " AND c.fk_statut = 0";
|
$sql.= " AND c.fk_statut = 0";
|
||||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
@ -247,7 +247,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
|
|||||||
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('commande').")";
|
||||||
//$sql.= " AND c.fk_statut > 2";
|
//$sql.= " AND c.fk_statut > 2";
|
||||||
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
|
if ($socid) $sql .= " AND c.fk_soc = ".$socid;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
@ -328,7 +328,7 @@ if (! empty($conf->commande->enabled))
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('commande').")";
|
||||||
$sql.= " AND c.fk_statut = 1";
|
$sql.= " AND c.fk_statut = 1";
|
||||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
@ -410,7 +410,7 @@ if (! empty($conf->commande->enabled))
|
|||||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('commande', 1).")";
|
$sql.= " AND c.entity IN (".getEntity('commande').")";
|
||||||
$sql.= " AND c.fk_statut = 2 ";
|
$sql.= " AND c.fk_statut = 2 ";
|
||||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
|
|||||||
@ -468,7 +468,7 @@ if ($search_user > 0)
|
|||||||
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||||
}
|
}
|
||||||
$sql.= ' WHERE c.fk_soc = s.rowid';
|
$sql.= ' WHERE c.fk_soc = s.rowid';
|
||||||
$sql.= ' AND c.entity IN ('.getEntity('commande', 1).')';
|
$sql.= ' AND c.entity IN ('.getEntity('commande').')';
|
||||||
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
|
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
|
||||||
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
|
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
|
|||||||
@ -548,7 +548,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
|
|||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
|
||||||
$sql.= ', '.MAIN_DB_PREFIX.'commande as c';
|
$sql.= ', '.MAIN_DB_PREFIX.'commande as c';
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= ' WHERE c.entity IN ('.getEntity('commande', 1).')';
|
$sql.= ' WHERE c.entity IN ('.getEntity('commande').')';
|
||||||
$sql.= ' AND c.fk_soc = s.rowid';
|
$sql.= ' AND c.fk_soc = s.rowid';
|
||||||
|
|
||||||
// Show orders with status validated, shipping started and delivered (well any order we can bill)
|
// Show orders with status validated, shipping started and delivered (well any order we can bill)
|
||||||
|
|||||||
@ -90,7 +90,7 @@ $sql.= ", date_format(b.dateo,'%Y-%m') as dm";
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.amount >= 0";
|
$sql.= " AND b.amount >= 0";
|
||||||
if (! empty($id))
|
if (! empty($id))
|
||||||
$sql .= " AND b.fk_account IN (".$db->escape($id).")";
|
$sql .= " AND b.fk_account IN (".$db->escape($id).")";
|
||||||
@ -118,7 +118,7 @@ $sql.= ", date_format(b.dateo,'%Y-%m') as dm";
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.amount <= 0";
|
$sql.= " AND b.amount <= 0";
|
||||||
if (! empty($id))
|
if (! empty($id))
|
||||||
$sql .= " AND b.fk_account IN (".$db->escape($id).")";
|
$sql .= " AND b.fk_account IN (".$db->escape($id).")";
|
||||||
@ -250,7 +250,7 @@ $sql = "SELECT SUM(b.amount) as total";
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if (! empty($id))
|
if (! empty($id))
|
||||||
$sql.= " AND b.fk_account IN (".$db->escape($id).")";
|
$sql.= " AND b.fk_account IN (".$db->escape($id).")";
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")";
|
if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
@ -321,7 +321,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'";
|
$sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'";
|
||||||
$sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'";
|
$sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'";
|
||||||
$sql.= " AND b.amount > 0";
|
$sql.= " AND b.amount > 0";
|
||||||
@ -410,7 +410,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'";
|
$sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'";
|
||||||
$sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'";
|
$sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'";
|
||||||
$sql.= " AND b.amount < 0";
|
$sql.= " AND b.amount < 0";
|
||||||
|
|||||||
@ -463,7 +463,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
|||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if ($account > 0) $sql.=" AND b.fk_account = ".$account;
|
if ($account > 0) $sql.=" AND b.fk_account = ".$account;
|
||||||
// Search period criteria
|
// Search period criteria
|
||||||
if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'";
|
if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'";
|
||||||
@ -861,7 +861,7 @@ if ($resql)
|
|||||||
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,";
|
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,";
|
||||||
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b";
|
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sqlforbalance.= " WHERE b.fk_account = ba.rowid";
|
$sqlforbalance.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sqlforbalance.= " AND b.fk_account = ".$account;
|
$sqlforbalance.= " AND b.fk_account = ".$account;
|
||||||
$sqlforbalance.= " AND b.datev < '" . $db->idate($db->jdate($objp->dv)) . "'";
|
$sqlforbalance.= " AND b.datev < '" . $db->idate($db->jdate($objp->dv)) . "'";
|
||||||
$resqlforbalance = $db->query($sqlforbalance);
|
$resqlforbalance = $db->query($sqlforbalance);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -1167,7 +1167,7 @@ class Account extends CommonObject
|
|||||||
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.rappro=0";
|
$sql.= " WHERE b.rappro=0";
|
||||||
$sql.= " AND b.fk_account = ba.rowid";
|
$sql.= " AND b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
|
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
|
||||||
$sql.= " AND clos = 0";
|
$sql.= " AND clos = 0";
|
||||||
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
|
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
|
||||||
@ -1224,7 +1224,7 @@ class Account extends CommonObject
|
|||||||
$sql = "SELECT COUNT(ba.rowid) as nb";
|
$sql = "SELECT COUNT(ba.rowid) as nb";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE ba.rappro > 0 and ba.clos = 0";
|
$sql.= " WHERE ba.rappro > 0 and ba.clos = 0";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2";
|
if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2";
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -1615,7 +1615,7 @@ class AccountLine extends CommonObject
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if ($num) $sql.= " AND b.num_chq='".$this->db->escape($num)."'";
|
if ($num) $sql.= " AND b.num_chq='".$this->db->escape($num)."'";
|
||||||
else if ($ref) $sql.= " AND b.rowid='".$this->db->escape($ref)."'";
|
else if ($ref) $sql.= " AND b.rowid='".$this->db->escape($ref)."'";
|
||||||
else $sql.= " AND b.rowid=".$rowid;
|
else $sql.= " AND b.rowid=".$rowid;
|
||||||
@ -2028,6 +2028,7 @@ class AccountLine extends CommonObject
|
|||||||
$result.=$langs->trans("BankAccount").': ';
|
$result.=$langs->trans("BankAccount").': ';
|
||||||
$accountstatic=new Account($this->db);
|
$accountstatic=new Account($this->db);
|
||||||
$accountstatic->id=$this->fk_account;
|
$accountstatic->id=$this->fk_account;
|
||||||
|
$accountstatic->ref=$this->bank_account_ref;
|
||||||
$accountstatic->label=$this->bank_account_label;
|
$accountstatic->label=$this->bank_account_label;
|
||||||
$result.=$accountstatic->getNomUrl(0).', ';
|
$result.=$accountstatic->getNomUrl(0).', ';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ class BankAccounts extends DolibarrApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t";
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('bank_account', 1).')';
|
$sql.= ' WHERE t.entity IN ('.getEntity('bank_account').')';
|
||||||
// Add sql filters
|
// Add sql filters
|
||||||
if ($sqlfilters)
|
if ($sqlfilters)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -92,7 +92,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
@ -133,7 +133,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
|
$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
|
||||||
$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
||||||
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
||||||
@ -164,7 +164,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev < '".$year."-".sprintf("%02s",$month)."-01'";
|
$sql.= " AND b.datev < '".$year."-".sprintf("%02s",$month)."-01'";
|
||||||
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
|
$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
|
||||||
$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
|
$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
|
||||||
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
||||||
@ -307,7 +307,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev < '".$year."-01-01'";
|
$sql.= " AND b.datev < '".$year."-01-01'";
|
||||||
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
||||||
|
|
||||||
@ -415,7 +415,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
|
||||||
$sql.= " GROUP BY date_format(b.datev,'%Y%m%d')";
|
$sql.= " GROUP BY date_format(b.datev,'%Y%m%d')";
|
||||||
|
|
||||||
@ -538,7 +538,7 @@ else
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
|
$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
|
||||||
$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
||||||
$sql.= " AND b.amount > 0";
|
$sql.= " AND b.amount > 0";
|
||||||
@ -576,7 +576,7 @@ else
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
|
$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
|
||||||
$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
||||||
$sql.= " AND b.amount < 0";
|
$sql.= " AND b.amount < 0";
|
||||||
@ -656,7 +656,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
|
$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
|
||||||
$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
|
$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
|
||||||
$sql.= " AND b.amount > 0";
|
$sql.= " AND b.amount > 0";
|
||||||
@ -685,7 +685,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
|
$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
|
||||||
$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
|
$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
|
||||||
$sql.= " AND b.amount < 0";
|
$sql.= " AND b.amount < 0";
|
||||||
|
|||||||
@ -152,7 +152,7 @@ $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // N
|
|||||||
$sql.=$hookmanager->resPrint;
|
$sql.=$hookmanager->resPrint;
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b";
|
||||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bankcacount_extrafields as ef on (c.rowid = ef.fk_object)";
|
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bankcacount_extrafields as ef on (c.rowid = ef.fk_object)";
|
||||||
$sql.= " WHERE entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " WHERE entity IN (".getEntity('bank_account').")";
|
||||||
if ($statut == 'opened') $sql.= " AND clos = 0";
|
if ($statut == 'opened') $sql.= " AND clos = 0";
|
||||||
if ($statut == 'closed') $sql.= " AND clos = 1";
|
if ($statut == 'closed') $sql.= " AND clos = 1";
|
||||||
if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref);
|
if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref);
|
||||||
|
|||||||
@ -476,7 +476,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
|
|||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id";
|
||||||
$sql.= " , ".MAIN_DB_PREFIX."user as u";
|
$sql.= " , ".MAIN_DB_PREFIX."user as u";
|
||||||
$sql.= " WHERE s.entity IN (".getEntity('user',1).")";
|
$sql.= " WHERE s.entity IN (".getEntity('user').")";
|
||||||
$sql.= " AND u.rowid = s.fk_user";
|
$sql.= " AND u.rowid = s.fk_user";
|
||||||
if ($year > 0)
|
if ($year > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -93,7 +93,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE s.fk_stcomm = st.id AND s.client in (1, 3)";
|
$sql.= " WHERE s.fk_stcomm = st.id AND s.client in (1, 3)";
|
||||||
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
|
$sql.= " AND s.entity IN (".getEntity('societe').")";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if (dol_strlen($stcomm))
|
if (dol_strlen($stcomm))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -223,7 +223,7 @@ class Deplacement extends CommonObject
|
|||||||
{
|
{
|
||||||
$sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet, extraparams";
|
$sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet, extraparams";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."deplacement";
|
$sql.= " FROM ".MAIN_DB_PREFIX."deplacement";
|
||||||
$sql.= " WHERE entity IN (".getEntity('deplacement').")";
|
$sql.= " WHERE entity IN (".getEntity('deplacement', 0).")";
|
||||||
if ($ref) $sql.= " AND ref ='".$this->db->escape($ref)."'";
|
if ($ref) $sql.= " AND ref ='".$this->db->escape($ref)."'";
|
||||||
else $sql.= " AND rowid = ".$id;
|
else $sql.= " AND rowid = ".$id;
|
||||||
|
|
||||||
|
|||||||
@ -120,7 +120,7 @@ class InvoiceApi extends DolibarrApi
|
|||||||
|
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||||
|
|
||||||
$sql.= ' WHERE s.entity IN ('.getEntity('facture', 1).')';
|
$sql.= ' WHERE s.entity IN ('.getEntity('facture').')';
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc";
|
||||||
if ($socid) $sql.= " AND s.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND s.fk_soc = ".$socid;
|
||||||
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class Invoices extends DolibarrApi
|
|||||||
|
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||||
|
|
||||||
$sql.= ' WHERE t.entity IN ('.getEntity('facture', 1).')';
|
$sql.= ' WHERE t.entity IN ('.getEntity('facture').')';
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
|
||||||
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
|
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
|
||||||
|
|
||||||
|
|||||||
@ -955,7 +955,7 @@ class FactureRec extends CommonInvoice
|
|||||||
|
|
||||||
$sql = "SELECT rowid";
|
$sql = "SELECT rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||||
$sql.= " WHERE entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE entity IN (".getEntity('product').")";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3757,7 +3757,7 @@ class Facture extends CommonInvoice
|
|||||||
$prodids = array();
|
$prodids = array();
|
||||||
$sql = "SELECT rowid";
|
$sql = "SELECT rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||||
$sql.= " WHERE entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE entity IN (".getEntity('product').")";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -3965,7 +3965,7 @@ class Facture extends CommonInvoice
|
|||||||
function newCycle()
|
function newCycle()
|
||||||
{
|
{
|
||||||
$sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f';
|
$sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f';
|
||||||
$sql.= " WHERE f.entity in (".getEntity('facture').")";
|
$sql.= " WHERE f.entity in (".getEntity('facture', 0).")";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
if ($resql->num_rows > 0)
|
if ($resql->num_rows > 0)
|
||||||
|
|||||||
@ -384,7 +384,7 @@ if ($search_user > 0)
|
|||||||
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||||
}
|
}
|
||||||
$sql.= ' WHERE f.fk_soc = s.rowid';
|
$sql.= ' WHERE f.fk_soc = s.rowid';
|
||||||
$sql.= ' AND f.entity IN ('.getEntity('facture', 1).')';
|
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
|
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
|
||||||
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
|
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
|
||||||
|
|||||||
@ -416,7 +416,7 @@ if ($action == 'new')
|
|||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
|
||||||
$sql.= " WHERE b.fk_type = 'CHQ'";
|
$sql.= " WHERE b.fk_type = 'CHQ'";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.fk_bordereau = 0";
|
$sql.= " AND b.fk_bordereau = 0";
|
||||||
$sql.= " AND b.amount > 0";
|
$sql.= " AND b.amount > 0";
|
||||||
if ($filterdate) $sql.=" AND b.dateo = '".$db->idate($filterdate)."'";
|
if ($filterdate) $sql.=" AND b.dateo = '".$db->idate($filterdate)."'";
|
||||||
@ -656,7 +656,7 @@ else
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
|
||||||
$sql.= " WHERE ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " WHERE ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.fk_type= 'CHQ'";
|
$sql.= " AND b.fk_type= 'CHQ'";
|
||||||
$sql.= " AND b.fk_bordereau = ".$object->id;
|
$sql.= " AND b.fk_bordereau = ".$object->id;
|
||||||
$sql.= $db->order($sortfield, $sortorder);
|
$sql.= $db->order($sortfield, $sortorder);
|
||||||
|
|||||||
@ -496,7 +496,7 @@ class RemiseCheque extends CommonObject
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.fk_type = 'CHQ'";
|
$sql.= " AND b.fk_type = 'CHQ'";
|
||||||
$sql.= " AND b.fk_bordereau = 0";
|
$sql.= " AND b.fk_bordereau = 0";
|
||||||
$sql.= " AND b.amount > 0";
|
$sql.= " AND b.amount > 0";
|
||||||
|
|||||||
@ -56,7 +56,7 @@ $sql = "SELECT count(b.rowid)";
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
$sql.= " WHERE ba.rowid = b.fk_account";
|
$sql.= " WHERE ba.rowid = b.fk_account";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " AND b.fk_type = 'CHQ'";
|
$sql.= " AND b.fk_type = 'CHQ'";
|
||||||
$sql.= " AND b.fk_bordereau = 0";
|
$sql.= " AND b.fk_bordereau = 0";
|
||||||
$sql.= " AND b.amount > 0";
|
$sql.= " AND b.amount > 0";
|
||||||
|
|||||||
@ -263,7 +263,7 @@ if ($modecompta != 'CREANCES-DETTES')
|
|||||||
$sql.= " WHERE pf.rowid IS NULL";
|
$sql.= " WHERE pf.rowid IS NULL";
|
||||||
$sql.= " AND p.fk_bank = b.rowid";
|
$sql.= " AND p.fk_bank = b.rowid";
|
||||||
$sql.= " AND b.fk_account = ba.rowid";
|
$sql.= " AND b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if (! empty($date_start) && ! empty($date_end))
|
if (! empty($date_start) && ! empty($date_end))
|
||||||
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||||
$sql.= " GROUP BY name, idp";
|
$sql.= " GROUP BY name, idp";
|
||||||
@ -654,7 +654,7 @@ if (! empty($conf->expensereport->enabled))
|
|||||||
$sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
|
$sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||||
$sql.= " WHERE p.entity = ".getEntity('expensereport',1);
|
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||||
$sql.= " AND p.fk_statut>=5";
|
$sql.= " AND p.fk_statut>=5";
|
||||||
|
|
||||||
$column='p.date_valid';
|
$column='p.date_valid';
|
||||||
@ -664,7 +664,7 @@ if (! empty($conf->expensereport->enabled))
|
|||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||||
$sql.= " WHERE p.entity = ".getEntity('expensereport',1);
|
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||||
$sql.= " AND p.fk_statut>=5";
|
$sql.= " AND p.fk_statut>=5";
|
||||||
|
|
||||||
$column='pe.datep';
|
$column='pe.datep';
|
||||||
@ -745,7 +745,7 @@ if (! empty($conf->don->enabled))
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||||
$sql.= " WHERE p.entity = ".getEntity('donation',1);
|
$sql.= " WHERE p.entity = ".getEntity('donation');
|
||||||
$sql.= " AND fk_statut >= 2";
|
$sql.= " AND fk_statut >= 2";
|
||||||
}
|
}
|
||||||
if (! empty($date_start) && ! empty($date_end))
|
if (! empty($date_start) && ! empty($date_end))
|
||||||
|
|||||||
@ -164,7 +164,7 @@ if ($modecompta != 'CREANCES-DETTES')
|
|||||||
$sql.= " WHERE pf.rowid IS NULL";
|
$sql.= " WHERE pf.rowid IS NULL";
|
||||||
$sql.= " AND p.fk_bank = b.rowid";
|
$sql.= " AND p.fk_bank = b.rowid";
|
||||||
$sql.= " AND b.fk_account = ba.rowid";
|
$sql.= " AND b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " GROUP BY dm";
|
$sql.= " GROUP BY dm";
|
||||||
$sql.= " ORDER BY dm";
|
$sql.= " ORDER BY dm";
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ if (! empty($conf->expensereport->enabled))
|
|||||||
$sql = "SELECT date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
|
$sql = "SELECT date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||||
$sql.= " WHERE p.entity = ".getEntity('expensereport',1);
|
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||||
$sql.= " AND p.fk_statut>=5";
|
$sql.= " AND p.fk_statut>=5";
|
||||||
|
|
||||||
$column='p.date_valid';
|
$column='p.date_valid';
|
||||||
@ -547,7 +547,7 @@ if (! empty($conf->expensereport->enabled))
|
|||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||||
$sql.= " WHERE p.entity = ".getEntity('expensereport',1);
|
$sql.= " WHERE p.entity = ".getEntity('expensereport');
|
||||||
$sql.= " AND p.fk_statut>=5";
|
$sql.= " AND p.fk_statut>=5";
|
||||||
|
|
||||||
$column='pe.datep';
|
$column='pe.datep';
|
||||||
@ -600,7 +600,7 @@ if (! empty($conf->don->enabled))
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
||||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||||
$sql.= " WHERE p.entity = ".getEntity('donation',1);
|
$sql.= " WHERE p.entity = ".getEntity('donation');
|
||||||
$sql.= " AND fk_statut >= 2";
|
$sql.= " AND fk_statut >= 2";
|
||||||
}
|
}
|
||||||
$sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm";
|
$sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm";
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
/* Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||||
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
|
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
|
||||||
@ -405,7 +405,7 @@ if ($id)
|
|||||||
{
|
{
|
||||||
if (! empty($user->rights->salaries->delete))
|
if (! empty($user->rights->salaries->delete))
|
||||||
{
|
{
|
||||||
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -413,7 +413,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
|
|||||||
|
|
||||||
$sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary";
|
$sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u";
|
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u";
|
||||||
$sql.= " WHERE s.entity IN (".getEntity('user',1).")";
|
$sql.= " WHERE s.entity IN (".getEntity('user').")";
|
||||||
$sql.= " AND u.rowid = s.fk_user";
|
$sql.= " AND u.rowid = s.fk_user";
|
||||||
if ($year > 0)
|
if ($year > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -237,7 +237,7 @@ if ($modecompta != 'CREANCES-DETTES') {
|
|||||||
$sql.= " WHERE pf.rowid IS NULL";
|
$sql.= " WHERE pf.rowid IS NULL";
|
||||||
$sql.= " AND p.fk_bank = b.rowid";
|
$sql.= " AND p.fk_bank = b.rowid";
|
||||||
$sql.= " AND b.fk_account = ba.rowid";
|
$sql.= " AND b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if ($date_start && $date_end) {
|
if ($date_start && $date_end) {
|
||||||
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -306,7 +306,7 @@ if ($modecompta != 'CREANCES-DETTES') {
|
|||||||
$sql.= " WHERE pf.rowid IS NULL";
|
$sql.= " WHERE pf.rowid IS NULL";
|
||||||
$sql.= " AND p.fk_bank = b.rowid";
|
$sql.= " AND p.fk_bank = b.rowid";
|
||||||
$sql.= " AND b.fk_account = ba.rowid";
|
$sql.= " AND b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||||
$sql.= " GROUP BY socid, name";
|
$sql.= " GROUP BY socid, name";
|
||||||
$sql.= " ORDER BY name";
|
$sql.= " ORDER BY name";
|
||||||
|
|||||||
@ -151,7 +151,7 @@ if ($modecompta != 'CREANCES-DETTES')
|
|||||||
$sql.= " WHERE pf.rowid IS NULL";
|
$sql.= " WHERE pf.rowid IS NULL";
|
||||||
$sql.= " AND p.fk_bank = b.rowid";
|
$sql.= " AND p.fk_bank = b.rowid";
|
||||||
$sql.= " AND b.fk_account = ba.rowid";
|
$sql.= " AND b.fk_account = ba.rowid";
|
||||||
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
|
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||||
$sql.= " GROUP BY dm";
|
$sql.= " GROUP BY dm";
|
||||||
$sql.= " ORDER BY dm";
|
$sql.= " ORDER BY dm";
|
||||||
|
|
||||||
|
|||||||
@ -324,14 +324,4 @@ $dolibarr_nocsrfcheck='0';
|
|||||||
// External module
|
// External module
|
||||||
//##############################
|
//##############################
|
||||||
|
|
||||||
// multicompany_transverse_mode
|
|
||||||
// Prerequisite: Need external module "multicompany"
|
|
||||||
// Pyramidal (0): The rights and groups are managed in each entity. Each user belongs to the entity he was created into.
|
|
||||||
// Transversal (1): The user is created and managed only into master entity but can login to all entities if he is admmin
|
|
||||||
// of entity or belongs to at least one user group created into entity.
|
|
||||||
|
|
||||||
// Default value: 0 (pyramidal)
|
|
||||||
// Examples:
|
|
||||||
// $multicompany_transverse_mode='1';
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -247,7 +247,7 @@ if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_conta
|
|||||||
if (! empty($search_categ_thirdparty)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
|
if (! empty($search_categ_thirdparty)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
|
||||||
if (! empty($search_categ_supplier)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ
|
if (! empty($search_categ_supplier)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
||||||
$sql.= ' WHERE p.entity IN ('.getEntity('societe', 1).')';
|
$sql.= ' WHERE p.entity IN ('.getEntity('societe').')';
|
||||||
if (!$user->rights->societe->client->voir && !$socid) //restriction
|
if (!$user->rights->societe->client->voir && !$socid) //restriction
|
||||||
{
|
{
|
||||||
$sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)";
|
$sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)";
|
||||||
|
|||||||
@ -504,7 +504,7 @@ class Contrat extends CommonObject
|
|||||||
if ($ref)
|
if ($ref)
|
||||||
{
|
{
|
||||||
$sql.= " WHERE ref='".$this->db->escape($ref)."'";
|
$sql.= " WHERE ref='".$this->db->escape($ref)."'";
|
||||||
$sql.= " AND entity IN (".getEntity('contract').")";
|
$sql.= " AND entity IN (".getEntity('contract', 0).")";
|
||||||
}
|
}
|
||||||
else $sql.= " WHERE rowid=".$id;
|
else $sql.= " WHERE rowid=".$id;
|
||||||
|
|
||||||
@ -2180,7 +2180,7 @@ class Contrat extends CommonObject
|
|||||||
$prodids = array();
|
$prodids = array();
|
||||||
$sql = "SELECT rowid";
|
$sql = "SELECT rowid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||||
$sql.= " WHERE entity IN (".getEntity('product', 1).")";
|
$sql.= " WHERE entity IN (".getEntity('product').")";
|
||||||
$sql.= " AND tosell = 1";
|
$sql.= " AND tosell = 1";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@ -107,7 +107,7 @@ $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
|
|||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
|
$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
|
||||||
$sql.= " AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= '".$db->idate($now)."')))";
|
$sql.= " AND (cd.statut != 4 OR (cd.statut = 4 AND (cd.date_fin_validite is null or cd.date_fin_validite >= '".$db->idate($now)."')))";
|
||||||
$sql.= " AND c.entity IN (".getEntity('contract').")";
|
$sql.= " AND c.entity IN (".getEntity('contract', 0).")";
|
||||||
if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
|
if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
$sql.= " GROUP BY cd.statut";
|
$sql.= " GROUP BY cd.statut";
|
||||||
@ -144,7 +144,7 @@ $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
|
|||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
|
$sql.= " WHERE cd.fk_contrat = c.rowid AND c.fk_soc = s.rowid";
|
||||||
$sql.= " AND (cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now)."')";
|
$sql.= " AND (cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now)."')";
|
||||||
$sql.= " AND c.entity IN (".getEntity('contract').")";
|
$sql.= " AND c.entity IN (".getEntity('contract', 0).")";
|
||||||
if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
|
if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id;
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
$sql.= " GROUP BY cd.statut";
|
$sql.= " GROUP BY cd.statut";
|
||||||
@ -230,7 +230,7 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
|
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE s.rowid = c.fk_soc";
|
$sql.= " WHERE s.rowid = c.fk_soc";
|
||||||
$sql.= " AND c.entity IN (".getEntity('contract').")";
|
$sql.= " AND c.entity IN (".getEntity('contract', 0).")";
|
||||||
$sql.= " AND c.statut = 0";
|
$sql.= " AND c.statut = 0";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND c.fk_soc = ".$socid;
|
||||||
@ -302,7 +302,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= " ".MAIN_DB_PREFIX.
|
|||||||
$sql.= " ".MAIN_DB_PREFIX."contrat as c";
|
$sql.= " ".MAIN_DB_PREFIX."contrat as c";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid";
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
||||||
$sql.= " AND c.entity IN (".getEntity('contract').")";
|
$sql.= " AND c.entity IN (".getEntity('contract', 0).")";
|
||||||
$sql.= " AND c.statut > 0";
|
$sql.= " AND c.statut > 0";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||||
@ -372,7 +372,7 @@ $sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
|||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
|
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
|
||||||
$sql.= ") LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
$sql.= ") LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||||
$sql.= " WHERE c.entity IN (".getEntity('contract').")";
|
$sql.= " WHERE c.entity IN (".getEntity('contract', 0).")";
|
||||||
$sql.= " AND cd.fk_contrat = c.rowid";
|
$sql.= " AND cd.fk_contrat = c.rowid";
|
||||||
$sql.= " AND c.fk_soc = s.rowid";
|
$sql.= " AND c.fk_soc = s.rowid";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
@ -450,7 +450,7 @@ $sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
|||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
|
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
|
||||||
$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||||
$sql.= " WHERE c.entity IN (".getEntity('contract').")";
|
$sql.= " WHERE c.entity IN (".getEntity('contract', 0).")";
|
||||||
$sql.= " AND c.statut = 1";
|
$sql.= " AND c.statut = 1";
|
||||||
$sql.= " AND cd.statut = 0";
|
$sql.= " AND cd.statut = 0";
|
||||||
$sql.= " AND cd.fk_contrat = c.rowid";
|
$sql.= " AND cd.fk_contrat = c.rowid";
|
||||||
@ -529,7 +529,7 @@ $sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
|||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
|
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
|
||||||
$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
$sql.= " ) LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||||
$sql.= " WHERE c.entity IN (".getEntity('contract').")";
|
$sql.= " WHERE c.entity IN (".getEntity('contract', 0).")";
|
||||||
$sql.= " AND c.statut = 1";
|
$sql.= " AND c.statut = 1";
|
||||||
$sql.= " AND cd.statut = 4";
|
$sql.= " AND cd.statut = 4";
|
||||||
$sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'";
|
$sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'";
|
||||||
|
|||||||
@ -222,7 +222,7 @@ if ($search_user > 0)
|
|||||||
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||||
}
|
}
|
||||||
$sql.= " WHERE c.fk_soc = s.rowid ";
|
$sql.= " WHERE c.fk_soc = s.rowid ";
|
||||||
$sql.= ' AND c.entity IN ('.getEntity('contract', 1).')';
|
$sql.= ' AND c.entity IN ('.getEntity('contract').')';
|
||||||
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
|
if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
|
||||||
if ($socid) $sql.= " AND s.rowid = ".$db->escape($socid);
|
if ($socid) $sql.= " AND s.rowid = ".$db->escape($socid);
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
|
|||||||
@ -90,7 +90,7 @@ class box_clients extends ModeleBoxes
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE s.client IN (1, 3)";
|
$sql.= " WHERE s.client IN (1, 3)";
|
||||||
$sql.= " AND s.entity IN (".getEntity('societe', 1).")";
|
$sql.= " AND s.entity IN (".getEntity('societe').")";
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($user->societe_id) $sql.= " AND s.rowid = $user->societe_id";
|
if ($user->societe_id) $sql.= " AND s.rowid = $user->societe_id";
|
||||||
$sql.= " ORDER BY s.tms DESC";
|
$sql.= " ORDER BY s.tms DESC";
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class box_contacts extends ModeleBoxes
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
|
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
|
||||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")";
|
$sql.= " WHERE sp.entity IN (".getEntity('societe').")";
|
||||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id;
|
if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id;
|
||||||
$sql.= " ORDER BY sp.tms DESC";
|
$sql.= " ORDER BY sp.tms DESC";
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user