Merge pull request #18923 from aspangaro/15a24
NEW Societe - Add perentity functionality on customer/supplier accountancy auxiliary account
This commit is contained in:
commit
e3045f24cd
@ -191,7 +191,14 @@ print '<script type="text/javascript">
|
||||
*/
|
||||
$sql = "SELECT f.rowid as facid, f.ref as ref, f.type, f.datef, f.ref_client,";
|
||||
$sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_client,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " spe.accountancy_code_customer as code_compta_client,";
|
||||
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
|
||||
} else {
|
||||
$sql .= " s.code_compta as code_compta_client,";
|
||||
$sql .= " s.code_compta_fournisseur,";
|
||||
}
|
||||
$sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label,";
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,";
|
||||
@ -201,7 +208,7 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " aa.rowid as fk_compte, aa.account_number, aa.label as label_account, aa.labelshort as labelshort_account,";
|
||||
$sql .= " fd.situation_percent,";
|
||||
$sql .= " co.code as country_code, co.label as country,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
@ -213,6 +220,9 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
|
||||
$sql .= " WHERE fd.fk_code_ventilation > 0";
|
||||
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
|
||||
|
||||
@ -240,10 +240,14 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " p.tosell as status, p.tobuy as status_buy,";
|
||||
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,";
|
||||
$sql .= " co.code as country_code, co.label as country_label,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " spe.accountancy_code_customer as code_compta_client,";
|
||||
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
|
||||
$sql .= " spe.accountancy_code_sell as company_code_sell";
|
||||
} else {
|
||||
$sql .= " s.code_compta as code_compta_client,";
|
||||
$sql .= " s.code_compta_fournisseur,";
|
||||
$sql .= " s.accountancy_code_sell as company_code_sell";
|
||||
}
|
||||
$parameters = array();
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2017-2021 Frédéric France <frederic.france@netlogic.fr>
|
||||
@ -119,7 +119,14 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
|
||||
|
||||
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,";
|
||||
$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
|
||||
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
|
||||
$sql .= " soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " spe.accountancy_code_customer as code_compta,";
|
||||
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
|
||||
} else {
|
||||
$sql .= " soc.code_compta,";
|
||||
$sql .= " soc.code_compta_fournisseur,";
|
||||
}
|
||||
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, u.statut as userstatus,";
|
||||
$sql .= " bu2.type as typeop_user,";
|
||||
$sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier";
|
||||
@ -130,6 +137,9 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid A
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc on bu1.url_id=soc.rowid";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = soc.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid";
|
||||
$sql .= " WHERE ba.fk_accountancy_journal=".((int) $id_journal);
|
||||
$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy
|
||||
|
||||
@ -105,7 +105,14 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
|
||||
|
||||
$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlr, f.close_code,";
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " spe.accountancy_code_customer as code_compta,";
|
||||
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
|
||||
} else {
|
||||
$sql .= " s.code_compta as code_compta,";
|
||||
$sql .= " s.code_compta_fournisseur,";
|
||||
}
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " ppe.accountancy_code_buy,";
|
||||
} else {
|
||||
@ -120,6 +127,9 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$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";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
$sql .= " WHERE f.fk_statut > 0";
|
||||
$sql .= " AND fd.fk_code_ventilation > 0";
|
||||
$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
|
||||
|
||||
@ -107,7 +107,14 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
|
||||
|
||||
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code,";
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " spe.accountancy_code_customer as code_compta,";
|
||||
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
|
||||
} else {
|
||||
$sql .= " s.code_compta as code_compta,";
|
||||
$sql .= " s.code_compta_fournisseur,";
|
||||
}
|
||||
$sql .= " p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " ppe.accountancy_code_sell";
|
||||
@ -122,6 +129,9 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
|
||||
$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";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
$sql .= " WHERE fd.fk_code_ventilation > 0";
|
||||
$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";
|
||||
|
||||
@ -202,7 +202,14 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
|
||||
}
|
||||
$sql .= " co.code as country_code, co.label as country,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", spe.accountancy_code_customer as code_compta_client";
|
||||
$sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
|
||||
} else {
|
||||
$sql .= ", s.code_compta as code_compta_client";
|
||||
$sql .= ", s.code_compta_fournisseur";
|
||||
}
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
@ -214,6 +221,9 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
|
||||
$sql .= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
|
||||
// Add search filter like
|
||||
|
||||
@ -243,10 +243,14 @@ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " p.tosell as status, p.tobuy as status_buy,";
|
||||
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,";
|
||||
$sql .= " co.code as country_code, co.label as country_label,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " spe.accountancy_code_customer as code_compta_client,";
|
||||
$sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
|
||||
$sql .= " spe.accountancy_code_buy as company_code_buy";
|
||||
} else {
|
||||
$sql .= " s.code_compta as code_compta_client,";
|
||||
$sql .= " s.code_compta_fournisseur,";
|
||||
$sql .= " s.accountancy_code_buy as company_code_buy";
|
||||
}
|
||||
$parameters = array();
|
||||
|
||||
@ -86,13 +86,23 @@ class box_contacts extends ModeleBoxes
|
||||
|
||||
$sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
|
||||
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
|
||||
$sql .= ", s.code_client, s.code_compta, s.client";
|
||||
$sql .= ", s.code_client, s.client";
|
||||
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", spe.accountancy_code_customer as code_compta";
|
||||
$sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
|
||||
} else {
|
||||
$sql .= ", s.code_compta";
|
||||
$sql .= ", s.code_compta_fournisseur";
|
||||
}
|
||||
$sql .= ", s.logo, s.email, s.entity";
|
||||
$sql .= ", co.label as country, co.code as country_code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
|
||||
@ -88,7 +88,12 @@ class box_factures_imp extends ModeleBoxes
|
||||
|
||||
if ($user->rights->facture->lire) {
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
|
||||
$sql .= ", s.code_client, s.code_compta, s.client";
|
||||
$sql .= ", s.code_client, s.client";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", spe.accountancy_code_customer as code_compta";
|
||||
} else {
|
||||
$sql .= ", s.code_compta";
|
||||
}
|
||||
$sql .= ", s.logo, s.email, s.entity";
|
||||
$sql .= ", s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
|
||||
$sql .= ", f.ref, f.date_lim_reglement as datelimite";
|
||||
@ -100,6 +105,9 @@ class box_factures_imp extends ModeleBoxes
|
||||
$sql .= ", f.paye, f.fk_statut as status, f.rowid as facid";
|
||||
$sql .= ", sum(pf.amount) as am";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
@ -115,7 +123,12 @@ class box_factures_imp extends ModeleBoxes
|
||||
if ($user->socid) {
|
||||
$sql .= " AND s.rowid = ".((int) $user->socid);
|
||||
}
|
||||
$sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,";
|
||||
$sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " spe.accountancy_code_customer as code_compta,";
|
||||
} else {
|
||||
$sql .= " s.code_compta,";
|
||||
}
|
||||
$sql .= " f.ref, f.date_lim_reglement,";
|
||||
$sql .= " f.type, f.datef, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.fk_statut, f.rowid";
|
||||
//$sql.= " ORDER BY f.datef DESC, f.ref DESC ";
|
||||
|
||||
@ -252,17 +252,32 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode
|
||||
*/
|
||||
public function checkIfAccountancyCodeIsAlreadyUsed($db, $code, $type = '')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($type == 'supplier') {
|
||||
$typethirdparty = 'code_compta_fournisseur';
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$typethirdparty = 'accountancy_code_supplier';
|
||||
} else {
|
||||
$typethirdparty = 'code_compta_fournisseur';
|
||||
}
|
||||
} elseif ($type == 'customer') {
|
||||
$typethirdparty = 'code_compta';
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$typethirdparty = 'accountancy_code_customer';
|
||||
} else {
|
||||
$typethirdparty = 'code_compta';
|
||||
}
|
||||
} else {
|
||||
$this->error = 'Bad value for parameter type';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "SELECT ".$typethirdparty." FROM ".MAIN_DB_PREFIX."societe";
|
||||
$sql .= " WHERE ".$typethirdparty." = '".$db->escape($code)."'";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql = "SELECT " . $typethirdparty . " FROM " . MAIN_DB_PREFIX . "societe_perentity";
|
||||
$sql .= " WHERE " . $typethirdparty . " = '" . $db->escape($code) . "'";
|
||||
} else {
|
||||
$sql = "SELECT " . $typethirdparty . " FROM " . MAIN_DB_PREFIX . "societe";
|
||||
$sql .= " WHERE " . $typethirdparty . " = '" . $db->escape($code) . "'";
|
||||
}
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
|
||||
@ -229,9 +229,17 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
* List last modified supliers
|
||||
*/
|
||||
$max = 10;
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur, s.code_compta_fournisseur";
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
|
||||
} else {
|
||||
$sql .= ", s.code_compta_fournisseur";
|
||||
}
|
||||
$sql .= ", st.libelle as stcomm";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
|
||||
@ -370,3 +370,7 @@ ALTER TABLE llx_hrm_skillrank ADD INDEX idx_hrm_skillrank_fk_skill (fk_skill);
|
||||
ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid);
|
||||
|
||||
--END GRH/HRM MODULE
|
||||
|
||||
-- Manage accountancy auxiliary account for thirdparties per entity
|
||||
ALTER TABLE llx_societe_perentity ADD COLUMN accountancy_code_customer varchar(24) AFTER entity; -- equivalent to code_compta in llx_societe
|
||||
ALTER TABLE llx_societe_perentity ADD COLUMN accountancy_code_supplier varchar(24) AFTER accountancy_code_customer; -- equivalent to code_compta_supplier in llx_societe
|
||||
|
||||
@ -37,9 +37,9 @@ create table llx_societe
|
||||
status tinyint DEFAULT 1, -- cessation d'activité ( 1 -- en activité, 0 -- cessation d'activité)
|
||||
|
||||
code_client varchar(24), -- code client
|
||||
code_fournisseur varchar(24), -- code founisseur
|
||||
code_compta varchar(24), -- code compta client
|
||||
code_compta_fournisseur varchar(24), -- code compta founisseur
|
||||
code_fournisseur varchar(24), -- code fournisseur
|
||||
code_compta varchar(24), -- customer accountancy auxiliary account
|
||||
code_compta_fournisseur varchar(24), -- supplier accountancy auxiliary account
|
||||
address varchar(255), -- company address
|
||||
zip varchar(25), -- zipcode
|
||||
town varchar(50), -- town
|
||||
|
||||
@ -21,8 +21,8 @@ create table llx_societe_perentity
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_soc integer,
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
-- code_compta varchar(24), -- code compta client
|
||||
-- code_compta_fournisseur varchar(24), -- code compta founisseur
|
||||
accountancy_code_customer varchar(24), -- customer accountancy auxiliary account
|
||||
accountancy_code_supplier varchar(24), -- supplier accountancy auxiliary account
|
||||
accountancy_code_sell varchar(32), -- Selling accountancy code
|
||||
accountancy_code_buy varchar(32) -- Buying accountancy code
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2013 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2011-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
@ -75,6 +75,9 @@ if (!empty($conf->incoterm->enabled)) {
|
||||
if (!empty($conf->notification->enabled)) {
|
||||
$langs->load("mails");
|
||||
}
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
$langs->load("products");
|
||||
}
|
||||
|
||||
$error = 0; $errors = array();
|
||||
|
||||
@ -443,19 +446,19 @@ if (empty($reshook)) {
|
||||
$object->name = dolGetFirstLastname(GETPOST('firstname', 'alphanohtml'), GETPOST('name', 'alphanohtml'));
|
||||
$object->civility_id = GETPOST('civility_id', 'alphanohtml'); // Note: civility id is a code, not an int
|
||||
// Add non official properties
|
||||
$object->name_bis = GETPOST('name', 'alphanohtml');
|
||||
$object->firstname = GETPOST('firstname', 'alphanohtml');
|
||||
$object->name_bis = GETPOST('name', 'alphanohtml');
|
||||
$object->firstname = GETPOST('firstname', 'alphanohtml');
|
||||
} else {
|
||||
$object->name = GETPOST('name', 'alphanohtml');
|
||||
$object->name = GETPOST('name', 'alphanohtml');
|
||||
}
|
||||
$object->entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : $conf->entity);
|
||||
$object->name_alias = GETPOST('name_alias', 'alphanohtml');
|
||||
$object->name_alias = GETPOST('name_alias', 'alphanohtml');
|
||||
$object->address = GETPOST('address', 'alphanohtml');
|
||||
$object->zip = GETPOST('zipcode', 'alphanohtml');
|
||||
$object->town = GETPOST('town', 'alphanohtml');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->state_id = GETPOST('state_id', 'int');
|
||||
//$object->skype = GETPOST('skype', 'alpha');
|
||||
$object->zip = GETPOST('zipcode', 'alphanohtml');
|
||||
$object->town = GETPOST('town', 'alphanohtml');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->state_id = GETPOST('state_id', 'int');
|
||||
//$object->skype = GETPOST('skype', 'alpha');
|
||||
//$object->twitter = GETPOST('twitter', 'alpha');
|
||||
//$object->facebook = GETPOST('facebook', 'alpha');
|
||||
//$object->linkedin = GETPOST('linkedin', 'alpha');
|
||||
@ -467,9 +470,9 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$object->phone = GETPOST('phone', 'alpha');
|
||||
$object->phone = GETPOST('phone', 'alpha');
|
||||
$object->fax = GETPOST('fax', 'alpha');
|
||||
$object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
|
||||
$object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
|
||||
$object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
|
||||
$object->idprof1 = trim(GETPOST('idprof1', 'alphanohtml'));
|
||||
$object->idprof2 = trim(GETPOST('idprof2', 'alphanohtml'));
|
||||
@ -479,7 +482,7 @@ if (empty($reshook)) {
|
||||
$object->idprof6 = trim(GETPOST('idprof6', 'alphanohtml'));
|
||||
$object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml');
|
||||
$object->code_client = GETPOSTISSET('customer_code') ?GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha');
|
||||
$object->code_fournisseur = GETPOSTISSET('supplier_code') ?GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha');
|
||||
$object->code_fournisseur = GETPOSTISSET('supplier_code') ?GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha');
|
||||
$object->capital = GETPOST('capital', 'alphanohtml');
|
||||
$object->barcode = GETPOST('barcode', 'alphanohtml');
|
||||
|
||||
@ -494,24 +497,24 @@ if (empty($reshook)) {
|
||||
$object->localtax1_value = GETPOST('lt1', 'alpha');
|
||||
$object->localtax2_value = GETPOST('lt2', 'alpha');
|
||||
|
||||
$object->forme_juridique_code = GETPOST('forme_juridique_code', 'int');
|
||||
$object->forme_juridique_code = GETPOST('forme_juridique_code', 'int');
|
||||
$object->effectif_id = GETPOST('effectif_id', 'int');
|
||||
$object->typent_id = GETPOST('typent_id', 'int');
|
||||
$object->typent_id = GETPOST('typent_id', 'int');
|
||||
|
||||
$object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type
|
||||
|
||||
$object->client = GETPOST('client', 'int');
|
||||
$object->client = GETPOST('client', 'int');
|
||||
$object->fournisseur = GETPOST('fournisseur', 'int');
|
||||
|
||||
$object->commercial_id = GETPOST('commercial_id', 'int');
|
||||
$object->default_lang = GETPOST('default_lang');
|
||||
$object->commercial_id = GETPOST('commercial_id', 'int');
|
||||
$object->default_lang = GETPOST('default_lang');
|
||||
|
||||
// Webservices url/key
|
||||
$object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
|
||||
$object->webservices_key = GETPOST('webservices_key', 'san_alpha');
|
||||
|
||||
if (GETPOSTISSET('accountancy_code_sell')) {
|
||||
$accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
|
||||
$accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
|
||||
|
||||
if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') {
|
||||
$object->accountancy_code_sell = '';
|
||||
@ -520,7 +523,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
if (GETPOSTISSET('accountancy_code_buy')) {
|
||||
$accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
|
||||
$accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
|
||||
|
||||
if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') {
|
||||
$object->accountancy_code_buy = '';
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
|
||||
* Copyright (C) 2010-2018 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
@ -563,11 +563,23 @@ class Societe extends CommonObject
|
||||
public $code_compta_client;
|
||||
|
||||
/**
|
||||
* Accounting code for suppliers
|
||||
* Accounting code for customer
|
||||
* @var string
|
||||
*/
|
||||
public $accountancy_code_customer;
|
||||
|
||||
/**
|
||||
* Accounting code for supplier
|
||||
* @var string
|
||||
*/
|
||||
public $code_compta_fournisseur;
|
||||
|
||||
/**
|
||||
* Accounting code for supplier
|
||||
* @var string
|
||||
*/
|
||||
public $accountancy_code_supplier;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @deprecated Note is split in public and private notes
|
||||
@ -838,6 +850,8 @@ class Societe extends CommonObject
|
||||
}
|
||||
$this->import_key = trim($this->import_key);
|
||||
|
||||
$this->accountancy_code_customer = trim($this->code_compta);
|
||||
$this->accountancy_code_supplier = trim($this->code_compta_fournisseur);
|
||||
$this->accountancy_code_buy = trim($this->accountancy_code_buy);
|
||||
$this->accountancy_code_sell= trim($this->accountancy_code_sell);
|
||||
|
||||
@ -922,11 +936,15 @@ class Societe extends CommonObject
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_perentity (";
|
||||
$sql .= " fk_soc";
|
||||
$sql .= ", entity";
|
||||
$sql .= ", accountancy_code_customer";
|
||||
$sql .= ", accountancy_code_supplier";
|
||||
$sql .= ", accountancy_code_buy";
|
||||
$sql .= ", accountancy_code_sell";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= $this->id;
|
||||
$sql .= ", " . $conf->entity;
|
||||
$sql .= ", '" . $this->db->escape($this->accountancy_code_customer) . "'";
|
||||
$sql .= ", '" . $this->db->escape($this->accountancy_code_supplier) . "'";
|
||||
$sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'";
|
||||
$sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'";
|
||||
$sql .= ")";
|
||||
@ -1281,7 +1299,7 @@ class Societe extends CommonObject
|
||||
}
|
||||
|
||||
$this->code_compta_client = trim(empty($this->code_compta) ? $this->code_compta_client : $this->code_compta);
|
||||
$this->code_compta = $this->code_compta_client; // for backward compatbility
|
||||
$this->code_compta = $this->code_compta_client; // for backward compatibility
|
||||
$this->code_compta_fournisseur = trim($this->code_compta_fournisseur);
|
||||
|
||||
// Check parameters. More tests are done later in the ->verify()
|
||||
@ -1451,6 +1469,14 @@ class Societe extends CommonObject
|
||||
if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy) . "'";
|
||||
$sql .= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell) . "'";
|
||||
|
||||
if ($customer) {
|
||||
$sql .= ", code_compta = ".(!empty($this->code_compta_client) ? "'".$this->db->escape($this->code_compta_client)."'" : "null");
|
||||
}
|
||||
|
||||
if ($supplier) {
|
||||
$sql .= ", code_compta_fournisseur = ".(($this->code_compta_fournisseur != "") ? "'".$this->db->escape($this->code_compta_fournisseur)."'" : "null");
|
||||
}
|
||||
}
|
||||
$sql .= ",webservices_url = ".(!empty($this->webservices_url) ? "'".$this->db->escape($this->webservices_url)."'" : "null");
|
||||
$sql .= ",webservices_key = ".(!empty($this->webservices_key) ? "'".$this->db->escape($this->webservices_key)."'" : "null");
|
||||
@ -1461,12 +1487,10 @@ class Societe extends CommonObject
|
||||
|
||||
if ($customer) {
|
||||
$sql .= ", code_client = ".(!empty($this->code_client) ? "'".$this->db->escape($this->code_client)."'" : "null");
|
||||
$sql .= ", code_compta = ".(!empty($this->code_compta_client) ? "'".$this->db->escape($this->code_compta_client)."'" : "null");
|
||||
}
|
||||
|
||||
if ($supplier) {
|
||||
$sql .= ", code_fournisseur = ".(!empty($this->code_fournisseur) ? "'".$this->db->escape($this->code_fournisseur)."'" : "null");
|
||||
$sql .= ", code_compta_fournisseur = ".(($this->code_compta_fournisseur != "") ? "'".$this->db->escape($this->code_compta_fournisseur)."'" : "null");
|
||||
}
|
||||
$sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : "null");
|
||||
$sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency;
|
||||
@ -1540,11 +1564,15 @@ class Societe extends CommonObject
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_perentity (";
|
||||
$sql .= " fk_soc";
|
||||
$sql .= ", entity";
|
||||
$sql .= ", accountancy_code_customer";
|
||||
$sql .= ", accountancy_code_supplier";
|
||||
$sql .= ", accountancy_code_buy";
|
||||
$sql .= ", accountancy_code_sell";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= $this->id;
|
||||
$sql .= ", " . $conf->entity;
|
||||
$sql .= ", '" . $this->db->escape($this->code_compta_client)."'";
|
||||
$sql .= ", '" . $this->db->escape($this->code_compta_fournisseur)."'";
|
||||
$sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'";
|
||||
$sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'";
|
||||
$sql .= ")";
|
||||
@ -1646,11 +1674,11 @@ class Societe extends CommonObject
|
||||
$sql .= ', s.fk_forme_juridique as forme_juridique_code';
|
||||
$sql .= ', s.webservices_url, s.webservices_key, s.model_pdf';
|
||||
if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ', s.accountancy_code_buy, s.accountancy_code_sell';
|
||||
$sql .= ', s.code_compta, s.code_compta_fournisseur, s.accountancy_code_buy, s.accountancy_code_sell';
|
||||
} else {
|
||||
$sql .= ', spe.accountancy_code_buy, spe.accountancy_code_sell';
|
||||
$sql .= ', spe.accountancy_code_customer as code_compta, spe.accountancy_code_supplier as code_compta_fournisseur, spe.accountancy_code_buy, spe.accountancy_code_sell';
|
||||
}
|
||||
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
|
||||
$sql .= ', s.code_client, s.code_fournisseur, s.parent, s.barcode';
|
||||
$sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.mode_reglement, s.cond_reglement, s.transport_mode';
|
||||
$sql .= ', s.fk_account, s.tva_assuj';
|
||||
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.transport_mode_supplier';
|
||||
@ -2011,6 +2039,15 @@ class Societe extends CommonObject
|
||||
|
||||
// Remove third party
|
||||
if (!$error) {
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_perentity";
|
||||
$sql .= " WHERE fk_soc = ".((int) $id);
|
||||
if (!$this->db->query($sql)) {
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe";
|
||||
$sql .= " WHERE rowid = ".((int) $id);
|
||||
if (!$this->db->query($sql)) {
|
||||
@ -3336,7 +3373,7 @@ class Societe extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Define parent commany of current company
|
||||
* Define parent company of current company
|
||||
*
|
||||
* @param int $id Id of thirdparty to set or '' to remove
|
||||
* @return int <0 if KO, >0 if OK
|
||||
|
||||
@ -263,12 +263,20 @@ $max = 15;
|
||||
$sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur";
|
||||
$sql .= ", s.code_client";
|
||||
$sql .= ", s.code_fournisseur";
|
||||
$sql .= ", s.code_compta_fournisseur";
|
||||
$sql .= ", s.code_compta";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur";
|
||||
$sql .= ", spe.accountancy_code_customer as code_compta";
|
||||
} else {
|
||||
$sql .= ", s.code_compta_fournisseur";
|
||||
$sql .= ", s.code_compta";
|
||||
}
|
||||
$sql .= ", s.logo";
|
||||
$sql .= ", s.entity";
|
||||
$sql .= ", s.canvas, s.tms as date_modification, s.status as status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
if (!$user->rights->societe->client->voir && !$socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
|
||||
@ -130,9 +130,17 @@ print '
|
||||
}
|
||||
</script>';
|
||||
|
||||
$sql = "(SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta as compta , ";
|
||||
$sql .= " s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , f.datec , f.fk_soc , cp.label as country ";
|
||||
$sql = "(SELECT s.rowid, s.nom as name , s.address, s.zip , s.town";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", spe.accountancy_code_customer as compta";
|
||||
} else {
|
||||
$sql .= ", s.code_compta";
|
||||
}
|
||||
$sql .= ", s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , f.datec , f.fk_soc , cp.label as country ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."c_country as cp";
|
||||
$sql .= " WHERE f.fk_soc = s.rowid";
|
||||
@ -146,9 +154,17 @@ if ($socid > 0) {
|
||||
}
|
||||
$sql .= " GROUP BY name";
|
||||
$sql .= ")";
|
||||
$sql .= "UNION (SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta_fournisseur as compta , ";
|
||||
$sql .= "UNION (SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, , ";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= ", spe.accountancy_code_supplier as compta";
|
||||
} else {
|
||||
$sql .= ", s.code_compta_fournisseur as compta";
|
||||
}
|
||||
$sql .= " s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , ff.datec , ff.fk_soc , cp.label as country ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as ff";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."c_country as cp";
|
||||
$sql .= " WHERE ff.fk_soc = s.rowid";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user