set facture to invoice AND check invoicenumber conf
This commit is contained in:
parent
e004fc2f5b
commit
c18f486179
@ -157,7 +157,7 @@ class Lettering extends BookKeeping
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON (bk.fk_doc = pay.fk_bank AND bk.code_journal='" . $obj->code_journal . "')";
|
||||
$sql .= " WHERE payfac.fk_paiement = '" . $obj->url_id . "' ";
|
||||
$sql .= " AND bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
|
||||
$sql .= " AND fac.entity IN (".getEntity('facture').")";
|
||||
$sql .= " AND fac.entity IN (".getEntity('invoice').")";
|
||||
$sql .= " AND ( ";
|
||||
if (! empty($object->code_compta)) {
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
|
||||
@ -185,7 +185,7 @@ class Lettering extends BookKeeping
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture fac ";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid AND fac.rowid IN (" . implode(',', $ids_fact) . "))";
|
||||
$sql .= " WHERE code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=2 AND entity=".$conf->entity.") ";
|
||||
$sql .= " AND fac.entity IN (".getEntity('facture').")";
|
||||
$sql .= " AND fac.entity IN (".getEntity('invoice').")";
|
||||
$sql .= " AND ( ";
|
||||
if (! empty($object->code_compta)) {
|
||||
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
|
||||
|
||||
@ -102,7 +102,7 @@ if (! empty($id)) {
|
||||
$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 .= " 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('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog("/accounting/customer/card.php sql=" . $sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -180,7 +180,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND aa.account_number IS NULL";
|
||||
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 . ")";
|
||||
@ -255,7 +255,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 .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
@ -332,7 +332,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 .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
@ -384,7 +384,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 .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
|
||||
@ -184,7 +184,7 @@ $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_factur
|
||||
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
||||
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
|
||||
$sql.= " WHERE fd.fk_code_ventilation > 0";
|
||||
$sql.= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql.= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql.= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
@ -245,7 +245,7 @@ if (strlen(trim($search_country))) {
|
||||
if (strlen(trim($search_tvaintra))) {
|
||||
$sql .= natural_search("s.tva_intra", $search_tvaintra);
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
|
||||
@ -288,7 +288,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
} 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.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
// Add where from hooks
|
||||
$parameters=array();
|
||||
|
||||
@ -107,7 +107,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid =
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
||||
$sql .= " WHERE fd.fk_code_ventilation > 0";
|
||||
$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy, we use source object sharing
|
||||
$sql .= " AND f.entity IN (".getEntity('invoice', 0).')'; // We don't share object for accountancy, we use source object sharing
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common setup
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
|
||||
@ -432,7 +432,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION))
|
||||
|
||||
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.fk_soc, u.email";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE entity IN (".getEntity('invoice').")";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -1146,7 +1146,7 @@ if ($object->id > 0)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
|
||||
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.tva, f.total_ttc,';
|
||||
$sql.= ' f.datef, f.datec, f.paye, f.fk_statut,';
|
||||
$sql.= ' s.nom, s.rowid';
|
||||
|
||||
@ -143,7 +143,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
|
||||
$sql.= " s.rowid as socid, s.nom as name, s.fournisseur";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid
|
||||
$sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice
|
||||
$sql.= " ORDER BY dlr ASC";
|
||||
|
||||
@ -739,7 +739,7 @@ if (empty($reshook))
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
|
||||
$sql.= ' WHERE pf.fk_facture = '.$object->id;
|
||||
$sql.= ' AND pf.fk_paiement = p.rowid';
|
||||
$sql.= ' AND p.entity IN (' . getEntity('facture').')';
|
||||
$sql.= ' AND p.entity IN (' . getEntity('invoice').')';
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) dol_print_error($db);
|
||||
@ -4284,7 +4284,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid';
|
||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
|
||||
$sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND pf.fk_paiement = p.rowid';
|
||||
$sql .= ' AND p.entity IN (' . getEntity('facture').')';
|
||||
$sql .= ' AND p.entity IN (' . getEntity('invoice').')';
|
||||
$sql .= ' ORDER BY p.datep, p.tms';
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
@ -123,7 +123,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
|
||||
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('facture').')';
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('invoice').')';
|
||||
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.")";
|
||||
|
||||
|
||||
@ -340,7 +340,7 @@ class FactureRec extends CommonInvoice
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
|
||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'";
|
||||
$sql.= ' WHERE f.entity IN ('.getEntity('facture').')';
|
||||
$sql.= ' WHERE f.entity IN ('.getEntity('invoice').')';
|
||||
if ($rowid) $sql.= ' AND f.rowid='.$rowid;
|
||||
elseif ($ref) $sql.= " AND f.titre='".$this->db->escape($ref)."'";
|
||||
/* This field are not used for template invoice
|
||||
|
||||
@ -1335,7 +1335,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid';
|
||||
|
||||
if ($rowid) $sql.= " WHERE f.rowid=".$rowid;
|
||||
else $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; // Dont't use entity if you use rowid
|
||||
else $sql.= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid
|
||||
|
||||
if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'";
|
||||
if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'";
|
||||
@ -3493,7 +3493,7 @@ class Facture extends CommonInvoice
|
||||
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."facture as f";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) //restriction
|
||||
{
|
||||
@ -3565,7 +3565,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source";
|
||||
$sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.paye = 0"; // Pas classee payee completement
|
||||
$sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait
|
||||
$sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement
|
||||
@ -3614,7 +3614,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")";
|
||||
// $sql.= " WHERE f.fk_statut >= 1";
|
||||
// $sql.= " AND (f.paye = 1"; // Classee payee completement
|
||||
@ -3830,7 +3830,7 @@ class Facture extends CommonInvoice
|
||||
$clause = " AND";
|
||||
}
|
||||
$sql.= $clause." f.paye=0";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED;
|
||||
if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id;
|
||||
|
||||
@ -4078,7 +4078,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= " WHERE sc.fk_user = " .$user->id;
|
||||
$clause = "AND";
|
||||
}
|
||||
$sql.= " ".$clause." f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " ".$clause." f.entity IN (".getEntity('invoice').")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -4152,7 +4152,7 @@ class Facture extends CommonInvoice
|
||||
function newCycle()
|
||||
{
|
||||
$sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f';
|
||||
$sql.= " WHERE f.entity in (".getEntity('facture', 0).")";
|
||||
$sql.= " WHERE f.entity in (".getEntity('invoice', 0).")";
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($resql->num_rows > 0)
|
||||
|
||||
@ -80,7 +80,7 @@ class FactureStats extends Stats
|
||||
}
|
||||
|
||||
$this->where = " f.fk_statut > 0";
|
||||
$this->where.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$this->where.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($mode == 'customer') $this->where.=" AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons)
|
||||
if ($this->socid)
|
||||
|
||||
@ -222,7 +222,7 @@ if (! $user->rights->societe->client->voir && ! $socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
|
||||
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
|
||||
if (! $user->rights->societe->client->voir && ! $socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ if ($search_user > 0)
|
||||
$sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||
}
|
||||
$sql.= ' WHERE f.fk_soc = s.rowid';
|
||||
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
|
||||
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
|
||||
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 = ".$db->escape($search_product_category);
|
||||
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
|
||||
|
||||
@ -146,7 +146,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
if ($socid)
|
||||
@ -236,7 +236,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').')';
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').')';
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
// Add where from hooks
|
||||
@ -331,7 +331,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.rowid = f.fk_soc";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
// Add where from hooks
|
||||
@ -823,7 +823,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').')';
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').')';
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
// Add where from hooks
|
||||
|
||||
@ -110,7 +110,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva as ct ON fd.tva_tx = ct.taux AND fd.i
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
|
||||
$sql.= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
|
||||
$sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc" ;
|
||||
$sql.= " WHERE f.fk_statut > 0 AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE f.fk_statut > 0 AND f.entity IN (".getEntity('invoice').")";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3)";
|
||||
if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
|
||||
@ -110,7 +110,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
|
||||
$sql.= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.fk_statut > 0";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql.= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
|
||||
|
||||
@ -528,7 +528,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,';
|
||||
$sql.= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql.= ' WHERE f.entity IN ('.getEntity('facture', $conf->entity).')';
|
||||
$sql.= ' WHERE f.entity IN ('.getEntity('invoice', $conf->entity).')';
|
||||
$sql.= ' AND (f.fk_soc = '.$facture->socid;
|
||||
// Can pay invoices of all child of parent company
|
||||
if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) {
|
||||
@ -846,7 +846,7 @@ if (! GETPOST('action','aZ09'))
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
|
||||
$sql.= ', '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql.= ' WHERE p.fk_facture = f.rowid';
|
||||
$sql.= ' AND f.entity IN (' . getEntity('facture').')';
|
||||
$sql.= ' AND f.entity IN (' . getEntity('invoice').')';
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= ' AND f.fk_soc = '.$socid;
|
||||
|
||||
@ -324,7 +324,7 @@ $sql = 'SELECT f.rowid as facid, f.facnumber,f.entity, f.type, f.total_ttc, f.pa
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s';
|
||||
$sql.= ' WHERE pf.fk_facture = f.rowid';
|
||||
$sql.= ' AND f.fk_soc = s.rowid';
|
||||
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
|
||||
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
|
||||
$sql.= ' AND pf.fk_paiement = '.$object->id;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -165,7 +165,7 @@ class Paiement extends CommonObject
|
||||
$sql.= ' b.fk_account';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
|
||||
$sql.= ' WHERE p.entity IN (' . getEntity('facture').')';
|
||||
$sql.= ' WHERE p.entity IN (' . getEntity('invoice').')';
|
||||
if ($id > 0)
|
||||
$sql.= ' AND p.rowid = '.$id;
|
||||
else if ($ref)
|
||||
|
||||
@ -118,7 +118,7 @@ if (GETPOST("orphelins"))
|
||||
$sql.=$hookmanager->resPrint;
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
|
||||
$sql.= " WHERE p.entity IN (" . getEntity('facture').")";
|
||||
$sql.= " WHERE p.entity IN (" . getEntity('invoice').")";
|
||||
$sql.= " AND pf.fk_facture IS NULL";
|
||||
// Add where from hooks
|
||||
$parameters=array();
|
||||
@ -149,7 +149,7 @@ else
|
||||
{
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
||||
}
|
||||
$sql.= " WHERE p.entity IN (" . getEntity('facture') . ")";
|
||||
$sql.= " WHERE p.entity IN (" . getEntity('invoice') . ")";
|
||||
if (! $user->rights->societe->client->voir && ! $socid)
|
||||
{
|
||||
$sql.= " AND sc.fk_user = " .$user->id;
|
||||
|
||||
@ -71,7 +71,7 @@ if ($socid)
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
|
||||
}
|
||||
$sql.= " WHERE p.entity IN (" . getEntity('facture') . ')';
|
||||
$sql.= " WHERE p.entity IN (" . getEntity('invoice') . ')';
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= " AND f.fk_soc = ".$socid;
|
||||
|
||||
@ -74,7 +74,7 @@ llxHeader('',$langs->trans("WithdrawalsReceipts"));
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('invoice').")";
|
||||
if ($search_ref) $sql.=natural_search("p.ref", $search_ref);
|
||||
if ($search_amount) $sql.=natural_search("p.amount", $search_amount, 1);
|
||||
|
||||
|
||||
@ -288,7 +288,7 @@ class BonPrelevement extends CommonObject
|
||||
$sql.= ", p.fk_user_credit";
|
||||
$sql.= ", p.statut";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('invoice').")";
|
||||
if ($rowid > 0) $sql.= " AND p.rowid = ".$rowid;
|
||||
else $sql.= " AND p.ref = '".$this->db->escape($ref)."'";
|
||||
|
||||
@ -699,7 +699,7 @@ class BonPrelevement extends CommonObject
|
||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
//$sql.= " ,".MAIN_DB_PREFIX."c_paiement as cp";
|
||||
$sql.= " WHERE f.fk_statut = 1";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.rowid = pfd.fk_facture";
|
||||
$sql.= " AND f.paye = 0";
|
||||
$sql.= " AND pfd.traite = 0";
|
||||
@ -740,7 +740,7 @@ class BonPrelevement extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
$sql.= " WHERE f.fk_statut = 1";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.rowid = pfd.fk_facture";
|
||||
$sql.= " AND f.paye = 0";
|
||||
$sql.= " AND pfd.traite = 0";
|
||||
@ -820,7 +820,7 @@ class BonPrelevement extends CommonObject
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
$sql.= " WHERE f.rowid = pfd.fk_facture";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').')';
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').')';
|
||||
$sql.= " AND s.rowid = f.fk_soc";
|
||||
//if ($banque || $agence) $sql.= " AND s.rowid = sr.fk_soc";
|
||||
$sql.= " AND f.fk_statut = 1";
|
||||
|
||||
@ -294,7 +294,7 @@ class RejetPrelevement
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_lignes as pl ON (pf.fk_prelevement_lignes = pl.rowid)";
|
||||
$sql.= " WHERE pf.fk_prelevement_lignes = ".$this->id;
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -194,7 +194,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
$sql.= " WHERE s.rowid = f.fk_soc";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND pfd.traite = 0";
|
||||
$sql.= " AND pfd.fk_facture = f.rowid";
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
@ -303,7 +303,7 @@ print load_fiche_titre($langs->trans("LastWithdrawalReceipts",$limit),'','');
|
||||
$sql = "SELECT p.rowid, p.ref, p.amount, p.statut";
|
||||
$sql.= ", p.datec";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " ORDER BY datec DESC";
|
||||
$sql.=$db->plimit($limit);
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ $sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.rowid = f.fk_soc";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
if (!$statut) $sql.= " AND pfd.traite = 0";
|
||||
|
||||
@ -155,7 +155,7 @@ $sql.= " WHERE pf.fk_prelevement_lignes = pl.rowid";
|
||||
$sql.= " AND pl.fk_prelevement_bons = p.rowid";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND pf.fk_facture = f.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if ($prev_id) $sql.= " AND p.rowid=".$prev_id;
|
||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
|
||||
@ -99,7 +99,7 @@ $sql.= " ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
$sql.= " WHERE s.rowid = f.fk_soc";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
|
||||
@ -272,7 +272,7 @@ if ($id)
|
||||
$sql.= " AND pl.fk_prelevement_bons = p.rowid";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND pf.fk_facture = f.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND pl.rowid=".$id;
|
||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||
$sql.= " ORDER BY $sortfield $sortorder ";
|
||||
|
||||
@ -94,7 +94,7 @@ $sql.= " WHERE pl.fk_prelevement_bons = p.rowid";
|
||||
$sql.= " AND pf.fk_prelevement_lignes = pl.rowid";
|
||||
$sql.= " AND pf.fk_facture = f.rowid";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||
if ($search_line) $sql.= " AND pl.rowid = '".$db->escape($search_line)."'";
|
||||
if ($search_bon) $sql.= natural_search("p.ref", $search_bon);
|
||||
|
||||
@ -122,7 +122,7 @@ if ($id > 0)
|
||||
$sql.= " u.login, u.rowid as userid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.fk_user_valid = u.rowid";
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
|
||||
|
||||
@ -371,7 +371,7 @@ else
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
$sql.= " GROUP BY name, socid";
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
@ -991,7 +991,7 @@ else
|
||||
$sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " GROUP BY dm";
|
||||
$newsortfield = $sortfield;
|
||||
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'dm';
|
||||
|
||||
@ -207,7 +207,7 @@ if (! empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $mo
|
||||
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if ($socid) $sql.= " AND f.fk_soc = $socid";
|
||||
$sql.= " GROUP BY dm";
|
||||
$sql.= " ORDER BY dm";
|
||||
@ -370,7 +370,7 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco
|
||||
$sql.= " WHERE f.fk_statut IN (1,2)";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
$sql.= " GROUP BY dm";
|
||||
|
||||
@ -259,7 +259,7 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
$sql.= ")";
|
||||
$sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid";
|
||||
}
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type";
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
|
||||
|
||||
@ -232,7 +232,7 @@ if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
}
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
$sql .= " GROUP BY u.rowid, u.lastname, u.firstname";
|
||||
$sql .= " ORDER BY u.rowid";
|
||||
|
||||
@ -291,7 +291,7 @@ if (!empty($search_societe)) $sql.= natural_search('s.nom', $search_societe);
|
||||
if (!empty($search_zip)) $sql.= natural_search('s.zip', $search_zip);
|
||||
if (!empty($search_town)) $sql.= natural_search('s.town', $search_town);
|
||||
if ($search_country > 0) $sql.= ' AND s.fk_pays = '.$search_country.'';
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
$sql.= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
|
||||
$sql.= " ORDER BY s.rowid";
|
||||
|
||||
@ -171,7 +171,7 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
$sql.= " WHERE f.fk_statut in (1,2)";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
}
|
||||
else if ($modecompta=="RECETTES-DEPENSES")
|
||||
@ -186,7 +186,7 @@ else if ($modecompta=="RECETTES-DEPENSES")
|
||||
$sql.= ", ".MAIN_DB_PREFIX."paiement as p";
|
||||
$sql.= " WHERE p.rowid = pf.fk_paiement";
|
||||
$sql.= " AND pf.fk_facture = f.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
}
|
||||
else if ($modecompta=="BOOKKEEPING")
|
||||
|
||||
@ -289,7 +289,7 @@ class box_activity extends ModeleBoxes
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
|
||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= ")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('facture').')';
|
||||
$sql.= " WHERE f.entity IN (".getEntity('invoice').')';
|
||||
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;
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
@ -371,7 +371,7 @@ class box_activity extends ModeleBoxes
|
||||
if ($refresh) {
|
||||
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('facture').')';
|
||||
$sql.= " WHERE f.entity IN (".getEntity('invoice').')';
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0";
|
||||
$sql.= " GROUP BY f.fk_statut";
|
||||
|
||||
@ -100,7 +100,7 @@ class box_factures extends ModeleBoxes
|
||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= ")";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
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 ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.facnumber DESC ";
|
||||
|
||||
@ -102,7 +102,7 @@ class box_factures_imp extends ModeleBoxes
|
||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.paye = 0";
|
||||
$sql.= " AND fk_statut = 1";
|
||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
|
||||
@ -6414,8 +6414,8 @@ class Form
|
||||
$possiblelinks=array(
|
||||
'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'),
|
||||
'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'),
|
||||
'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.facnumber as ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture').')'),
|
||||
'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture').')'),
|
||||
'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.facnumber as ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
|
||||
'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
|
||||
'contrat'=>array('enabled'=>$conf->contrat->enabled , 'perms'=>1, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'),
|
||||
'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'),
|
||||
'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'),
|
||||
|
||||
@ -167,7 +167,8 @@ class mod_facture_mars extends ModeleNumRefFactures
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
|
||||
$sql.= " AND entity = $entity";
|
||||
if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")";
|
||||
else $sql.= " AND entity = $entity";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
||||
@ -191,7 +192,8 @@ class mod_facture_mars extends ModeleNumRefFactures
|
||||
$sql = "SELECT facnumber as ref";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
|
||||
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
|
||||
if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")";
|
||||
else $sql.= " AND entity = $entity";
|
||||
|
||||
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
|
||||
@ -183,7 +183,8 @@ class mod_facture_terre extends ModeleNumRefFactures
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
|
||||
$sql.= " AND entity = $entity";
|
||||
if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")";
|
||||
else $sql.= " AND entity = $entity";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
||||
@ -207,7 +208,8 @@ class mod_facture_terre extends ModeleNumRefFactures
|
||||
$sql = "SELECT facnumber as ref";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
|
||||
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
|
||||
if(!empty($conf->global->MULTICOMPANY_INVOICENUMBER_SHARING_ENABLED)) $sql.= " AND entity IN (".getEntity('invoicenumber').")";
|
||||
else $sql.= " AND entity = $entity";
|
||||
|
||||
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
|
||||
@ -265,7 +265,7 @@ class modFacture extends DolibarrModules
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
|
||||
$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
|
||||
$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('facture').')';
|
||||
$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')';
|
||||
if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
|
||||
$r++;
|
||||
|
||||
@ -320,7 +320,7 @@ class modFacture extends DolibarrModules
|
||||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON b.rowid = p.fk_bank';
|
||||
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account';
|
||||
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
|
||||
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture').')';
|
||||
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('invoice').')';
|
||||
if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
|
||||
$r++;
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ class pdf_paiement
|
||||
$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
|
||||
if (! empty($conf->banque->enabled))
|
||||
$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
|
||||
if (! $user->rights->societe->client->voir && ! $socid)
|
||||
{
|
||||
|
||||
@ -516,7 +516,7 @@ if (empty($reshook))
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN (' . getEntity('c_paiement') . ')';
|
||||
$sql.= ' WHERE pf.fk_facturefourn = '.$object->id;
|
||||
$sql.= ' AND pf.fk_paiementfourn = p.rowid';
|
||||
$sql.= ' AND p.entity IN (' . getEntity('facture').')';
|
||||
$sql.= ' AND p.entity IN (' . getEntity('invoice').')';
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) dol_print_error($db);
|
||||
|
||||
@ -139,7 +139,7 @@ $sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
|
||||
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
|
||||
$sql.= " AND sc.fk_soc = f.fk_soc";
|
||||
$sql.= " AND (d.product_type = 0 OR d.product_type = 1)";
|
||||
if (! empty($conf->global->AGENT_CONTACT_TYPE))
|
||||
|
||||
@ -191,7 +191,7 @@ $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f ";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as d ON d.fk_facture = f.rowid";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON d.fk_product = p.rowid";
|
||||
$sql .= " WHERE f.fk_statut > 0";
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture') . ") ";
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice') . ") ";
|
||||
if (! empty($startdate)) $sql .= " AND f.datef >= '" . $db->idate($startdate) . "'";
|
||||
if (! empty($enddate)) $sql .= " AND f.datef <= '" . $db->idate($enddate) . "'";
|
||||
if ($search_ref) $sql.=natural_search('f.facnumber', $search_ref);
|
||||
|
||||
@ -189,7 +189,7 @@ if (! empty($TSelectedCats)) {
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=p.rowid';
|
||||
}
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= ' AND f.entity IN ('.getEntity('facture').')';
|
||||
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
|
||||
$sql.= " AND f.fk_statut > 0";
|
||||
$sql.= " AND d.fk_facture = f.rowid";
|
||||
if ($id > 0)
|
||||
|
||||
@ -154,7 +154,7 @@ if ($socid > 0)
|
||||
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.fk_statut > 0";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND d.fk_facture = f.rowid";
|
||||
$sql.= " AND f.fk_soc = $socid";
|
||||
$sql.= " AND d.buy_price_ht IS NOT NULL";
|
||||
|
||||
@ -2622,7 +2622,7 @@ class Product extends CommonObject
|
||||
}
|
||||
$sql.= " WHERE f.rowid = fd.fk_facture";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND fd.fk_product = ".$this->id;
|
||||
if (!$user->rights->societe->client->voir && !$socid) { $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
@ -2788,7 +2788,7 @@ class Product extends CommonObject
|
||||
if ($filteronproducttype >= 0) { $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype;
|
||||
}
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if (!$user->rights->societe->client->voir && !$socid) { $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
}
|
||||
if ($socid > 0) { $sql.= " AND f.fk_soc = $socid";
|
||||
|
||||
@ -418,7 +418,7 @@ function activitytrim($product_type)
|
||||
$sql = "SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, SUM(fd.total_ht) as Mnttot";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."paiement as p,".MAIN_DB_PREFIX."paiement_facture as pf";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " WHERE f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND f.rowid = fd.fk_facture";
|
||||
$sql.= " AND pf.fk_facture = f.rowid";
|
||||
$sql.= " AND pf.fk_paiement= p.rowid";
|
||||
|
||||
@ -155,7 +155,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$sql.= " AND d.fk_facture = f.rowid";
|
||||
$sql.= " AND d.fk_product =".$product->id;
|
||||
if (! empty($search_month))
|
||||
|
||||
@ -3804,7 +3804,7 @@ class Societe extends CommonObject
|
||||
if ($mode == 'supplier') {
|
||||
$sql .= " AND entity IN (".getEntity('facture_fourn').")";
|
||||
} else {
|
||||
$sql .= " AND entity IN (".getEntity('facture').")";
|
||||
$sql .= " AND entity IN (".getEntity('invoice').")";
|
||||
}
|
||||
|
||||
dol_syslog("getOutstandingBills", LOG_DEBUG);
|
||||
|
||||
@ -204,7 +204,7 @@ if ($type_element == 'invoice')
|
||||
$tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d";
|
||||
$where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid;
|
||||
$where.= " AND d.fk_facture = f.rowid";
|
||||
$where.= " AND f.entity IN (".getEntity('facture').")";
|
||||
$where.= " AND f.entity IN (".getEntity('invoice').")";
|
||||
$dateprint = 'f.datef';
|
||||
$doc_number='f.facnumber';
|
||||
$thirdTypeSelect='customer';
|
||||
|
||||
@ -770,7 +770,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)';
|
||||
}
|
||||
|
||||
$sql.= ' WHERE f.entity IN ('.getEntity('facture').")";
|
||||
$sql.= ' WHERE f.entity IN ('.getEntity('invoice').")";
|
||||
$sql.= ' AND (f.fk_soc = '.$facture->socid;
|
||||
|
||||
if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) {
|
||||
@ -1077,7 +1077,7 @@ if (! GETPOST('action'))
|
||||
$sql.=', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c';
|
||||
$sql.= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id';
|
||||
$sql.= ' AND f.entity IN ('.getEntity('facture').")";
|
||||
$sql.= ' AND f.entity IN ('.getEntity('invoice').")";
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= ' AND f.fk_soc = '.$socid;
|
||||
|
||||
@ -428,7 +428,7 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
|
||||
|
||||
$sql ='SELECT f.rowid as facid, facnumber as ref, ref_ext, type, fk_statut as status, total_ttc, total, tva';
|
||||
$sql.=' FROM '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql.=" WHERE f.entity IN (".getEntity('facture').")";
|
||||
$sql.=" WHERE f.entity IN (".getEntity('invoice').")";
|
||||
if ($idthirdparty != 'all' ) $sql.=" AND f.fk_soc = ".$db->escape($idthirdparty);
|
||||
|
||||
$resql=$db->query($sql);
|
||||
|
||||
@ -128,7 +128,7 @@ $sql .= " WHERE f.fk_soc = s.rowid";
|
||||
$sql .= " AND s.fk_pays = cp.rowid";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql .= " AND f.datec >= '" . $db->idate($date_start) . "' AND f.datec <= '" . $db->idate($date_end) . "'";
|
||||
$sql .= " AND f.entity IN (".getEntity('facture').")";
|
||||
$sql .= " AND f.entity IN (".getEntity('invoice').")";
|
||||
if ($socid)
|
||||
$sql .= " AND f.fk_soc = " . $socid;
|
||||
$sql .= " GROUP BY name";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user