From aaa9a4f47ccf8eccac487a5986e9ade40f3fdcf3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Nov 2018 17:27:49 +0100 Subject: [PATCH 01/10] FIX use getEntity('invoice') instead getEntity('facture') --- htdocs/accountancy/customer/card.php | 2 +- htdocs/accountancy/customer/index.php | 8 ++++---- htdocs/accountancy/customer/lines.php | 4 ++-- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 2 +- htdocs/admin/prelevement.php | 2 +- htdocs/compta/facture/card.php | 4 ++-- htdocs/compta/facture/class/api_invoices.class.php | 2 +- htdocs/compta/facture/class/facture-rec.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 4 ++-- htdocs/compta/facture/invoicetemplate_list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/compta/paiement.php | 12 ++++++------ htdocs/compta/paiement/class/paiement.class.php | 2 +- htdocs/compta/paiement/list.php | 4 ++-- htdocs/compta/paiement/tovalidate.php | 2 +- htdocs/compta/prelevement/bons.php | 2 +- .../prelevement/class/bonprelevement.class.php | 4 ++-- htdocs/compta/prelevement/create.php | 2 +- htdocs/compta/stats/byratecountry.php | 2 +- htdocs/core/boxes/box_activity.php | 4 ++-- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/modules/modFacture.class.php | 4 ++-- htdocs/fourn/facture/card.php | 2 +- htdocs/margin/agentMargins.php | 2 +- htdocs/margin/checkMargins.php | 2 +- htdocs/margin/productMargins.php | 2 +- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/stats/facture.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- 30 files changed, 47 insertions(+), 47 deletions(-) diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 677bc627c80..6b60296a5f4 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -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); diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 4f4932fe08f..ca75aaac15e 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -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 . ")"; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 7d8599b683c..f4ed9bad1f5 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -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 diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 74944b8f823..64a11fccc2a 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -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(); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 21736195073..f4729e6243d 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -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 . ")"; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 9fc4f46e54f..6d67cab60f9 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -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) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cafd59569bb..408eb3287ef 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -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); @@ -4281,7 +4281,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); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 5075d9d8cb7..1e6b1d35a8e 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -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.")"; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 56f87d2eac3..f302f4191f8 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -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 diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 227ae42b266..102661d3506 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1334,7 +1334,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)."'"; @@ -4142,7 +4142,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) diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index c0a80c86b74..c28b0917e1e 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -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; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 83925a38b08..2b289b9475a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -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; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 32e042c5731..c53556982e9 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -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)) { @@ -630,25 +630,25 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Date print ''.dol_print_date($db->jdate($objp->df),'day')."\n"; - + // Date Max Payment if ($objp->dlr > 0 ) { print ''; print dol_print_date($db->jdate($objp->dlr), 'day'); - + if ($invoice->hasDelay()) { print img_warning($langs->trans('Late')); } - + print ''; } else { print '--'; } - + // Currency if (!empty($conf->multicurrency->enabled)) print ''.$objp->multicurrency_code."\n"; @@ -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; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 18dabbcf980..cab87e4ff7b 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -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) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 768792c978c..6bd70e0aacc 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -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; diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 9fea9afa5df..a037326d9b1 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -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; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index e4fb8bc0757..cfe2e2a942c 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -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); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 4089ffd76e2..6470cf70490 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -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)."'"; @@ -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"; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 02ccee567f5..19fdbdffa23 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -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); diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index 99d6bb8b49d..e4fecab5060 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -281,7 +281,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } else { $sql.= " AND f.type IN (0,1,2,3,5)"; } -$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; +$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; $sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index bd3163268ac..413dc43d8b2 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -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"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9a1ac5cb834..2b47459c04a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -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').')'), diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index f8982ae2893..c187725e181 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -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++; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b6ff1d36551..3749489e290 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -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); diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 5c808051a06..71922b77aa2 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -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)) diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 06527f42b91..2f7b534fbba 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -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); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 23c9de6c321..8a741c3712e 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -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) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6d3a0724006..4fa89c20cac 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -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"; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index cd2dc221bb9..8b3cd4d9856 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -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)) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2411623e4aa..e69a7886d1e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -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); From 2350908d4e202134e440b74fa3401b8d352db8cb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Nov 2018 19:00:14 +0100 Subject: [PATCH 02/10] FIX change getEntity doc and changelog --- ChangeLog | 1 + htdocs/core/lib/functions.lib.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e4fbf63e758..921e4df28db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ NEW: Compatibility with PHP 7.3 For developers: * Code changes to be more compatible with PSR2 * Removed trigger USER_LOGOUT, USER_LOGIN, USER_LOGIN_FAILED (Some hooks are already dedicated for that) +* Change getEntity('invoice') instead getEntity('facture') WARNING: diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7bb634cde2a..f5b8861f32f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -107,7 +107,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) * @param string $element Current element * 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource', * 'product', 'productprice', 'stock', - * 'propal', 'supplier_proposal', 'facture', 'facture_fourn', 'payment_various', + * 'propal', 'supplier_proposal', 'invoice', 'facture_fourn', 'payment_various', * 'categorie', 'bank_account', 'bank_account', 'adherent', 'user', * 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', * 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', From 2d55666a0bbfde187bba42c4572906c8f51667ee Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 18 Nov 2018 21:50:58 +0100 Subject: [PATCH 03/10] NEW Add gender in member card --- htdocs/adherents/card.php | 32 ++++++++++++++-- htdocs/adherents/class/adherent.class.php | 38 +++++++++++-------- htdocs/adherents/list.php | 31 +++++++++++++-- htdocs/core/modules/modAdherent.class.php | 23 +++++------ .../install/mysql/migration/9.0.0-10.0.0.sql | 30 +++++++++++++++ htdocs/install/mysql/tables/llx_adherent.sql | 1 + 6 files changed, 120 insertions(+), 35 deletions(-) create mode 100644 htdocs/install/mysql/migration/9.0.0-10.0.0.sql diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 347c29fc30d..dec2ef6ec2e 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2012 Marcos García * Copyright (C) 2012-2018 Philippe Grand - * Copyright (C) 2015-2016 Alexandre Spangaro + * Copyright (C) 2015-2018 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -23,9 +23,9 @@ */ /** - * \file htdocs/adherents/card.php - * \ingroup member - * \brief Page of member + * \file htdocs/adherents/card.php + * \ingroup member + * \brief Page of member */ require '../main.inc.php'; @@ -249,6 +249,7 @@ if (empty($reshook)) } $lastname=$_POST["lastname"]; $firstname=$_POST["firstname"]; + $gender = $_POST["gender"]; $societe=$_POST["societe"]; $morphy=$_POST["morphy"]; $login=$_POST["login"]; @@ -284,6 +285,7 @@ if (empty($reshook)) $object->civility_id = trim(GETPOST("civility_id",'alpha')); $object->firstname = trim(GETPOST("firstname",'alpha')); $object->lastname = trim(GETPOST("lastname",'alpha')); + $object->gender = trim(GETPOST("gender",'alpha')); $object->login = trim(GETPOST("login",'alpha')); $object->pass = trim(GETPOST("pass",'alpha')); @@ -434,6 +436,7 @@ if (empty($reshook)) $civility_id=GETPOST("civility_id",'int'); $lastname=GETPOST("lastname",'alpha'); $firstname=GETPOST("firstname",'alpha'); + $gender=GETPOST("gender",'alpha'); $societe=GETPOST("societe",'alpha'); $address=GETPOST("address",'alpha'); $zip=GETPOST("zipcode",'alpha'); @@ -462,6 +465,7 @@ if (empty($reshook)) $object->civility_id = $civility_id; $object->firstname = $firstname; $object->lastname = $lastname; + $object->gender = $gender; $object->societe = $societe; $object->address = $address; $object->zip = $zip; @@ -954,6 +958,13 @@ else print ''.$langs->trans("Firstname").''; print ''; + // Gender + print ''.$langs->trans("Gender").''; + print ''; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1); + print ''; + // EMail print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').''; @@ -1196,6 +1207,13 @@ else print ''.$langs->trans("Firstname").'firstname).'">'; print ''; + // Gender + print ''.$langs->trans("Gender").''; + print ''; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1); + print ''; + // Photo print ''.$langs->trans("Photo").''; print ''; @@ -1580,6 +1598,12 @@ else print ''.$langs->trans("Nature").''.$object->getmorphylib().''; print ''; + // Gender + print ''.$langs->trans("Gender").''; + print ''; + if ($object->gender) print $langs->trans("Gender".$object->gender); + print ''; + // Company print ''.$langs->trans("Company").''.$object->societe.''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 9d6c5d02bb4..ed058d823da 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2009-2017 Regis Houssin - * Copyright (C) 2014-2016 Alexandre Spangaro + * Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Marcos García * Copyright (C) 2015-2018 Frédéric France * Copyright (C) 2015 Raphaël Doursenaud @@ -127,6 +127,7 @@ class Adherent extends CommonObject public $datem; public $datevalid; + public $gender; public $birth; public $note_public; @@ -457,17 +458,18 @@ class Adherent extends CommonObject dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=".$this->email); // Clean parameters - $this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->lastname); - $this->firstname=trim($this->firstname)?trim($this->firstname):trim($this->firstname); - $this->address=($this->address?$this->address:$this->address); - $this->zip=($this->zip?$this->zip:$this->zip); - $this->town=($this->town?$this->town:$this->town); - $this->country_id=($this->country_id > 0?$this->country_id:$this->country_id); - $this->state_id=($this->state_id > 0?$this->state_id:$this->state_id); + $this->lastname = trim($this->lastname)?trim($this->lastname):trim($this->lastname); + $this->firstname = trim($this->firstname)?trim($this->firstname):trim($this->firstname); + $this->gender = trim($this->gender); + $this->address = ($this->address?$this->address:$this->address); + $this->zip = ($this->zip?$this->zip:$this->zip); + $this->town = ($this->town?$this->town:$this->town); + $this->country_id = ($this->country_id > 0?$this->country_id:$this->country_id); + $this->state_id = ($this->state_id > 0?$this->state_id:$this->state_id); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords(trim($this->lastname)); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords(trim($this->firstname)); - $this->note_public=($this->note_public?$this->note_public:$this->note_public); - $this->note_private=($this->note_private?$this->note_private:$this->note_private); + $this->note_public = ($this->note_public?$this->note_public:$this->note_public); + $this->note_private = ($this->note_private?$this->note_private:$this->note_private); // Check parameters if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) @@ -483,6 +485,7 @@ class Adherent extends CommonObject $sql.= " civility = ".($this->civility_id?"'".$this->db->escape($this->civility_id)."'":"null"); $sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null"); $sql.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null"); + $sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' $sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null"); $sql.= ", societe = ".($this->societe?"'".$this->db->escape($this->societe)."'":"null"); $sql.= ", fk_soc = ".($this->fk_soc > 0?$this->db->escape($this->fk_soc):"null"); @@ -589,15 +592,16 @@ class Adherent extends CommonObject $luser->civility_id=$this->civility_id; $luser->firstname=$this->firstname; $luser->lastname=$this->lastname; + $luser->gender=$this->gender; $luser->pass=$this->pass; $luser->societe_id=$this->societe; $luser->birth=$this->birth; - $luser->address=$this->address; - $luser->zip=$this->zip; - $luser->town=$this->town; - $luser->country_id=$this->country_id; - $luser->state_id=$this->state_id; + $luser->address=$this->address; + $luser->zip=$this->zip; + $luser->town=$this->town; + $luser->country_id=$this->country_id; + $luser->state_id=$this->state_id; $luser->email=$this->email; $luser->skype=$this->skype; @@ -1129,7 +1133,7 @@ class Adherent extends CommonObject { global $langs; - $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; + $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql.= " d.note_public,"; $sql.= " d.email, d.skype, d.twitter, d.facebook, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; @@ -1176,6 +1180,7 @@ class Adherent extends CommonObject $this->civility_id = $obj->civility_id; $this->firstname = $obj->firstname; $this->lastname = $obj->lastname; + $this->gender = $obj->gender; $this->login = $obj->login; $this->societe = $obj->company; $this->company = $obj->company; @@ -2288,6 +2293,7 @@ class Adherent extends CommonObject $this->civility_id = 0; $this->lastname = 'DOLIBARR'; $this->firstname = 'SPECIMEN'; + $this->gender='man'; $this->login='dolibspec'; $this->pass='dolibspec'; $this->societe = 'Societe ABC'; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 39d0069ac7c..5156926d293 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2014-2016 Juanjo Menent + * Copyright (C) 2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,9 +21,9 @@ */ /** - * \file htdocs/adherents/list.php - * \ingroup member - * \brief Page to list all members of foundation + * \file htdocs/adherents/list.php + * \ingroup member + * \brief Page to list all members of foundation */ require '../main.inc.php'; @@ -48,6 +49,7 @@ $search=GETPOST("search",'alpha'); $search_ref=GETPOST("search_ref",'alpha'); $search_lastname=GETPOST("search_lastname",'alpha'); $search_firstname=GETPOST("search_firstname",'alpha'); +$search_gender=GETPOST("search_gender",'alpha'); $search_civility=GETPOST("search_civility",'alpha'); $search_login=GETPOST("search_login",'alpha'); $search_address=GETPOST("search_address",'alpha'); @@ -109,6 +111,7 @@ $arrayfields=array( 'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0), 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), 'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), + 'd.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0), 'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1), 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), 'd.morphy'=>array('label'=>$langs->trans("MorPhy"), 'checked'=>1), @@ -162,6 +165,7 @@ if (empty($reshook)) $search_ref=""; $search_lastname=""; $search_firstname=""; + $search_gender=""; $search_civility=""; $search_login=""; $search_company=""; @@ -205,7 +209,7 @@ $memberstatic=new Adherent($db); $now=dol_now(); -$sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,"; +$sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,"; $sql.= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; $sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; @@ -240,6 +244,7 @@ if ($search_ref) if ($search_civility) $sql.= natural_search("d.civility", $search_civility); if ($search_firstname) $sql.= natural_search("d.firstname", $search_firstname); if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname); +if ($search_gender != '' && $search_gender != '-1') $sql.= " AND d.gender = '".$search_gender."'"; if ($search_login) $sql.= natural_search("d.login", $search_login); if ($search_email) $sql.= natural_search("d.email", $search_email); if ($search_town) $sql.= natural_search("d.town",$search_town); @@ -329,6 +334,7 @@ if ($search_nom) $param.="&search_nom=".urlencode($search_nom); if ($search_civility) $param.="&search_civility=".urlencode($search_civility); if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname); if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); +if ($search_gender) $param.="&search_gender=".urlencode($search_gender); if ($search_login) $param.="&search_login=".urlencode($search_login); if ($search_email) $param.="&search_email=".urlencode($search_email); if ($search_company) $param.="&search_company=".urlencode($search_company); @@ -447,6 +453,13 @@ if (! empty($arrayfields['d.lastname']['checked'])) print ''; print ''; } +if (! empty($arrayfields['d.gender']['checked'])) +{ + print ''; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('search_gender', $arraygender, $search_gender, 1); + print ''; +} if (! empty($arrayfields['d.company']['checked'])) { print ''; @@ -575,6 +588,7 @@ if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titr if (! empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'],$_SERVER["PHP_SELF"],'d.civility','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.gender']['checked'])) print_liste_field_titre($arrayfields['d.gender']['label'],$_SERVER['PHP_SELF'],'d.gender',$param,"","",$sortfield,$sortorder); if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'],$_SERVER["PHP_SELF"],'d.societe','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'],$_SERVER["PHP_SELF"],'d.login','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'],$_SERVER["PHP_SELF"],'d.morphy','',$param,'',$sortfield,$sortorder); @@ -613,6 +627,7 @@ while ($i < min($num, $limit)) $memberstatic->civility_id=$obj->civility; $memberstatic->lastname=$obj->lastname; $memberstatic->firstname=$obj->firstname; + $memberstatic->gender=$obj->gender; $memberstatic->statut=$obj->statut; $memberstatic->datefin= $datefin; $memberstatic->socid = $obj->fk_soc; @@ -661,6 +676,14 @@ while ($i < min($num, $limit)) print $obj->lastname; print "\n"; } + // Gender + if (! empty($arrayfields['d.gender']['checked'])) + { + print ''; + if ($obj->gender) print $langs->trans("Gender".$obj->gender); + print ''; + if (! $i) $totalarray['nbfield']++; + } // Company if (! empty($arrayfields['d.company']['checked'])) { diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 9f09c01bfc7..71e99ea3de1 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -1,11 +1,12 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2014-2015 Raphaël Doursenaud +/* Copyright (C) 2003,2005 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2014-2015 Raphaël Doursenaud + * Copyright (C) 2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -268,7 +269,7 @@ class modAdherent extends DolibarrModules $this->export_label[$r]='MembersAndSubscriptions'; $this->export_permission[$r]=array(array("adherent","export")); $this->export_fields_array[$r]=array( - 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature', + 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature', 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', @@ -276,13 +277,13 @@ class modAdherent extends DolibarrModules 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' ); $this->export_TypeFields_array[$r]=array( - 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", + 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' ); $this->export_entities_array[$r]=array( - 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member', + 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member', 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', @@ -316,7 +317,7 @@ class modAdherent extends DolibarrModules $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array( - 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password", + 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password", "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql new file mode 100644 index 00000000000..c4e18c30672 --- /dev/null +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -0,0 +1,30 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 10.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. + +ALTER TABLE llx_adherent ADD gender VARCHAR(10); diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index 96da4ffb326..ede4de2e487 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -30,6 +30,7 @@ create table llx_adherent entity integer DEFAULT 1 NOT NULL, -- multi company id ref_ext varchar(128), -- reference into an external system (not used by dolibarr) + gender varchar(10), civility varchar(6), lastname varchar(50), firstname varchar(50), From cf0c4a5ce044e93424f57260be791a9dba85c75e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 18 Nov 2018 22:03:32 +0100 Subject: [PATCH 04/10] Add in public area --- htdocs/public/members/new.php | 18 +++++++++++++----- htdocs/public/members/public_card.php | 10 ++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 78b3ceb75db..b78534bf4b0 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -1,10 +1,11 @@ - * Copyright (C) 2001-2002 Jean-Louis Bergamo - * Copyright (C) 2006-2013 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2012 J. Fernando Lagrange +/* Copyright (C) 2001-2002 Rodolphe Quiedeville + * Copyright (C) 2001-2002 Jean-Louis Bergamo + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 J. Fernando Lagrange * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -232,6 +233,7 @@ if ($action == 'add') $adh->public = $public; $adh->firstname = $_POST["firstname"]; $adh->lastname = $_POST["lastname"]; + $adh->gender = $_POST["gender"]; $adh->civility_id = $_POST["civility_id"]; $adh->societe = $_POST["societe"]; $adh->address = $_POST["address"]; @@ -580,6 +582,12 @@ print $formcompany->select_civility(GETPOST('civility_id'),'civility_id').' print ''.$langs->trans("Lastname").' *'."\n"; // Firstname print ''.$langs->trans("Firstname").' *'."\n"; +// Gender +print ''.$langs->trans("Gender").''; +print ''; +$arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); +print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1); +print ''; // Company print ''.$langs->trans("Company").''."\n"; // Address diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index c7a9fa45b3a..c2df82fb2f2 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -1,8 +1,9 @@ - * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2007-2012 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin +/* Copyright (C) 2001-2003 Rodolphe Quiedeville + * Copyright (C) 2002-2003 Jean-Louis Bergamo + * Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,6 +92,7 @@ if ($id > 0) print ''.$langs->trans("Person").''.$object->morphy.''; print ''.$langs->trans("Firstname").''.$object->firstname.' '; print ''.$langs->trans("Lastname").''.$object->lastname.' '; + print ''.$langs->trans("Gender").''.$object->gender.' '; print ''.$langs->trans("Company").''.$object->societe.' '; print ''.$langs->trans("Address").''.nl2br($object->address).' '; print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''.$object->zip.' '.$object->town.' '; From 52efbfaba878f058c5aab531ab64a499d25b4f33 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 20 Nov 2018 06:53:49 +0100 Subject: [PATCH 05/10] Update travis test --- test/phpunit/AdherentTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index ed7dd35df36..21023c6f545 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -252,6 +252,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase //$localobject->note_public='New note public after update'; $localobject->lastname='New name'; $localobject->firstname='New firstname'; + $localobject->gender='man'; $localobject->address='New address'; $localobject->zip='New zip'; $localobject->town='New town'; @@ -284,6 +285,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase $this->assertEquals($localobject->note_public, $newobject->note_public); $this->assertEquals($localobject->lastname, $newobject->lastname); $this->assertEquals($localobject->firstname, $newobject->firstname); + $this->assertEquals($localobject->gender, $newobject->gender); $this->assertEquals($localobject->address, $newobject->address); $this->assertEquals($localobject->zip, $newobject->zip); $this->assertEquals($localobject->town, $newobject->town); From 6ea0919ebb2868c68bc31a0bd6077389fffda39f Mon Sep 17 00:00:00 2001 From: Chl Date: Fri, 17 Aug 2018 20:47:01 +0200 Subject: [PATCH 06/10] facture-rec.class.php: reindent --- .../facture/class/facture-rec.class.php | 93 ++++++++++--------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 56f87d2eac3..bf4360a57f3 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1025,30 +1025,33 @@ class FactureRec extends CommonInvoice $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; $sql.= ' AND suspended = 0'; $sql.= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here - if ($restictoninvoiceid > 0) $sql.=' AND rowid = '.$restictoninvoiceid; + if ($restictoninvoiceid > 0) + $sql.=' AND rowid = '.$restictoninvoiceid; $sql.= $db->order('entity', 'ASC'); //print $sql;exit; $resql = $db->query($sql); if ($resql) { - $i=0; - $num = $db->num_rows($resql); + $i=0; + $num = $db->num_rows($resql); - if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; - else $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); + if ($num) + $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; + else + $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); - $saventity = $conf->entity; + $saventity = $conf->entity; - while ($i < $num) // Loop on each template invoice. If $num = 0, test is false at first pass. + while ($i < $num) // Loop on each template invoice. If $num = 0, test is false at first pass. { $line = $db->fetch_object($resql); - $db->begin(); + $db->begin(); - $invoiceidgenerated = 0; + $invoiceidgenerated = 0; - $facturerec = new FactureRec($db); + $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); if ($facturerec->id > 0) @@ -1058,44 +1061,44 @@ class FactureRec extends CommonInvoice dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); - $facture = new Facture($db); + $facture = new Facture($db); $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice - $facture->type = self::TYPE_STANDARD; - $facture->brouillon = 1; - $facture->date = (empty($facturerec->date_when)?$now:$facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. - $facture->socid = $facturerec->socid; + $facture->type = self::TYPE_STANDARD; + $facture->brouillon = 1; + $facture->date = (empty($facturerec->date_when)?$now:$facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. + $facture->socid = $facturerec->socid; - $invoiceidgenerated = $facture->create($user); - if ($invoiceidgenerated <= 0) - { - $this->errors = $facture->errors; - $this->error = $facture->error; - $error++; - } - if (! $error && ($facturerec->auto_validate || $forcevalidation)) - { - $result = $facture->validate($user); - if ($result <= 0) - { - $this->errors = $facture->errors; - $this->error = $facture->error; - $error++; - } - } - if (! $error && $facturerec->generate_pdf) - { - // We refresh the object in order to have all necessary data (like date_lim_reglement) - $facture->fetch($facture->id); - $result = $facture->generateDocument($facturerec->modelpdf, $langs); - if ($result <= 0) - { - $this->errors = $facture->errors; - $this->error = $facture->error; - $error++; - } - } + $invoiceidgenerated = $facture->create($user); + if ($invoiceidgenerated <= 0) + { + $this->errors = $facture->errors; + $this->error = $facture->error; + $error++; + } + if (! $error && ($facturerec->auto_validate || $forcevalidation)) + { + $result = $facture->validate($user); + if ($result <= 0) + { + $this->errors = $facture->errors; + $this->error = $facture->error; + $error++; + } + } + if (! $error && $facturerec->generate_pdf) + { + // We refresh the object in order to have all necessary data (like date_lim_reglement) + $facture->fetch($facture->id); + $result = $facture->generateDocument($facturerec->modelpdf, $langs); + if ($result <= 0) + { + $this->errors = $facture->errors; + $this->error = $facture->error; + $error++; + } + } } else { @@ -1114,7 +1117,7 @@ class FactureRec extends CommonInvoice } else { - $db->rollback("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); + $db->rollback("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); } $i++; From 95b5d8790d27e856934f630873267d29f8b18489 Mon Sep 17 00:00:00 2001 From: Chl Date: Fri, 17 Aug 2018 19:56:29 +0200 Subject: [PATCH 07/10] corr. typo --- htdocs/compta/facture/class/facture-rec.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index bf4360a57f3..f35d8f88835 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -998,11 +998,11 @@ class FactureRec extends CommonInvoice * * WARNING: This method change temporarly context $conf->entity to be in correct context for each recurring invoice found. * - * @param int $restictoninvoiceid 0=All qualified template invoices found. > 0 = restrict action on invoice ID + * @param int $restrictioninvoiceid 0=All qualified template invoices found. > 0 = restrict action on invoice ID * @param int $forcevalidation 1=Force validation of invoice whatever is template auto_validate flag. * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function createRecurringInvoices($restictoninvoiceid=0, $forcevalidation=0) + function createRecurringInvoices($restrictioninvoiceid=0, $forcevalidation=0) { global $conf, $langs, $db, $user; @@ -1017,7 +1017,7 @@ class FactureRec extends CommonInvoice $tmparray=dol_getdate($now); $today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day - dol_syslog("createRecurringInvoices restictoninvoiceid=".$restictoninvoiceid." forcevalidation=".$forcevalidation); + dol_syslog("createRecurringInvoices restrictioninvoiceid=".$restrictioninvoiceid." forcevalidation=".$forcevalidation); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec'; $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency @@ -1025,8 +1025,8 @@ class FactureRec extends CommonInvoice $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; $sql.= ' AND suspended = 0'; $sql.= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here - if ($restictoninvoiceid > 0) - $sql.=' AND rowid = '.$restictoninvoiceid; + if ($restrictioninvoiceid > 0) + $sql.=' AND rowid = '.$restrictioninvoiceid; $sql.= $db->order('entity', 'ASC'); //print $sql;exit; From 864ce8534120747acc62c5d5d1ada43460056a1b Mon Sep 17 00:00:00 2001 From: Chl Date: Fri, 17 Aug 2018 20:39:46 +0200 Subject: [PATCH 08/10] NEW adding hooks to createRecurringInvoices() For example : send the newly generated invoice by mail. We send the counter and the total so launching some action on the last loop (generated invoice or error) is possible. (bonus: correcting error reporting $this->errors to $this->errors[] ) --- .../facture/class/facture-rec.class.php | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index f35d8f88835..6cff7e5ef57 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); /** @@ -1004,14 +1005,16 @@ class FactureRec extends CommonInvoice */ function createRecurringInvoices($restrictioninvoiceid=0, $forcevalidation=0) { - global $conf, $langs, $db, $user; + global $conf, $langs, $db, $user, $hookmanager; + $error=0; + $nb_create=0; // Load translation files required by the page - $langs->loadLangs(array("main","bills")); + $langs->loadLangs(array("main","bills")); - $nb_create=0; + $hookmanager->initHooks(array('createrecurringinvoices')); $now = dol_now(); $tmparray=dol_getdate($now); @@ -1029,6 +1032,12 @@ class FactureRec extends CommonInvoice $sql.=' AND rowid = '.$restrictioninvoiceid; $sql.= $db->order('entity', 'ASC'); //print $sql;exit; + $parameters = array( + 'entity' => $conf->entity, + 'restrictioninvoiceid' => $restrictioninvoiceid, + 'forcevalidation' => $forcevalidation, + ); + $reshook = $hookmanager->executeHooks('writeSQL', $parameters, $sql); // note that $sql might be modified by hooks $resql = $db->query($sql); if ($resql) @@ -1051,6 +1060,7 @@ class FactureRec extends CommonInvoice $invoiceidgenerated = 0; + $facture = null; $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); @@ -1073,7 +1083,7 @@ class FactureRec extends CommonInvoice $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) { - $this->errors = $facture->errors; + $this->errors[] = $facture->errors; $this->error = $facture->error; $error++; } @@ -1082,7 +1092,7 @@ class FactureRec extends CommonInvoice $result = $facture->validate($user); if ($result <= 0) { - $this->errors = $facture->errors; + $this->errors[] = $facture->errors; $this->error = $facture->error; $error++; } @@ -1094,7 +1104,7 @@ class FactureRec extends CommonInvoice $result = $facture->generateDocument($facturerec->modelpdf, $langs); if ($result <= 0) { - $this->errors = $facture->errors; + $this->errors[] = $facture->errors; $this->error = $facture->error; $error++; } @@ -1120,6 +1130,16 @@ class FactureRec extends CommonInvoice $db->rollback("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); } + $parameters = array( + 'cpt' => $i, + 'total' => $num, + 'errorCount' => $error, + 'invoiceidgenerated' => $invoiceidgenerated, + 'facturerec' => $facturerec, // it's an object which PHP passes by "reference", so modifiable by hooks. + 'this' => $this, // it's an object which PHP passes by "reference", so modifiable by hooks. + ); + $reshook = $hookmanager->executeHooks('generatedInvoice', $parameters, $facture); // note: $facture can be modified by hooks (warning: $facture can be null) + $i++; } From b67101c77cf00f6164baff4b2cd15b8c97cd7b26 Mon Sep 17 00:00:00 2001 From: Chl Date: Mon, 3 Dec 2018 17:03:28 +0100 Subject: [PATCH 09/10] corr. #10154 --- htdocs/compta/facture/class/facture-rec.class.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 6cff7e5ef57..fed1ca8c79c 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -32,7 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); /** @@ -1033,7 +1032,6 @@ class FactureRec extends CommonInvoice $sql.= $db->order('entity', 'ASC'); //print $sql;exit; $parameters = array( - 'entity' => $conf->entity, 'restrictioninvoiceid' => $restrictioninvoiceid, 'forcevalidation' => $forcevalidation, ); @@ -1083,7 +1081,7 @@ class FactureRec extends CommonInvoice $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) { - $this->errors[] = $facture->errors; + $this->errors = $facture->errors; $this->error = $facture->error; $error++; } @@ -1092,7 +1090,7 @@ class FactureRec extends CommonInvoice $result = $facture->validate($user); if ($result <= 0) { - $this->errors[] = $facture->errors; + $this->errors = $facture->errors; $this->error = $facture->error; $error++; } @@ -1104,7 +1102,7 @@ class FactureRec extends CommonInvoice $result = $facture->generateDocument($facturerec->modelpdf, $langs); if ($result <= 0) { - $this->errors[] = $facture->errors; + $this->errors = $facture->errors; $this->error = $facture->error; $error++; } From c377350c357615b381ef29b677e4f2c58e623a32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Dec 2018 16:09:12 +0100 Subject: [PATCH 10/10] Update facture-rec.class.php --- htdocs/compta/facture/class/facture-rec.class.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index fed1ca8c79c..23d30f0ad32 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1006,15 +1006,12 @@ class FactureRec extends CommonInvoice { global $conf, $langs, $db, $user, $hookmanager; - $error=0; $nb_create=0; // Load translation files required by the page $langs->loadLangs(array("main","bills")); - $hookmanager->initHooks(array('createrecurringinvoices')); - $now = dol_now(); $tmparray=dol_getdate($now); $today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day @@ -1035,7 +1032,7 @@ class FactureRec extends CommonInvoice 'restrictioninvoiceid' => $restrictioninvoiceid, 'forcevalidation' => $forcevalidation, ); - $reshook = $hookmanager->executeHooks('writeSQL', $parameters, $sql); // note that $sql might be modified by hooks + $reshook = $hookmanager->executeHooks('beforeCreationOfRecurringInvoices', $parameters, $sql); // note that $sql might be modified by hooks $resql = $db->query($sql); if ($resql) @@ -1136,7 +1133,7 @@ class FactureRec extends CommonInvoice 'facturerec' => $facturerec, // it's an object which PHP passes by "reference", so modifiable by hooks. 'this' => $this, // it's an object which PHP passes by "reference", so modifiable by hooks. ); - $reshook = $hookmanager->executeHooks('generatedInvoice', $parameters, $facture); // note: $facture can be modified by hooks (warning: $facture can be null) + $reshook = $hookmanager->executeHooks('afterCreationOfRecurringInvoice', $parameters, $facture); // note: $facture can be modified by hooks (warning: $facture can be null) $i++; }