From 6b5b10fc949fd04451a595a59cb14c33beca904c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Aug 2017 16:28:34 +0200 Subject: [PATCH 1/9] FIX #7224 --- htdocs/product/class/productcustomerprice.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 5b9050077c9..b3066df8188 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -169,12 +169,12 @@ class Productcustomerprice extends CommonObject $sql .= " " . (empty($this->price_min_ttc) ? '0' : "'" . $this->price_min_ttc . "'") . ","; $sql .= " " . (! isset($this->price_base_type) ? 'NULL' : "'" . $this->db->escape($this->price_base_type) . "'") . ","; $sql .= " ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " " . (! isset($this->tva_tx) ? 'NULL' : "'" . $this->tva_tx . "'") . ","; + $sql .= " " . (! isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx)?0:$this->tva_tx)) . ","; $sql .= " " . (! isset($this->recuperableonly) ? 'NULL' : "'" . $this->recuperableonly . "'") . ","; $sql .= " " . (empty($this->localtax1_type) ? "'0'" : "'" . $this->localtax1_type . "'") . ","; - $sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : "'" . $this->localtax1_tx . "'") . ","; + $sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx)?0:$this->localtax1_tx)) . ","; $sql .= " " . (empty($this->localtax2_type) ? "'0'" : "'" . $this->localtax2_type . "'") . ","; - $sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : "'" . $this->localtax2_tx . "'") . ","; + $sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx)?0:$this->localtax2_tx)) . ","; $sql .= " " . $user->id . ","; $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ""; $sql .= ")"; @@ -656,10 +656,10 @@ class Productcustomerprice extends CommonObject $sql .= " price_min_ttc=" . (isset($this->price_min_ttc) ? $this->price_min_ttc : "null") . ","; $sql .= " price_base_type=" . (isset($this->price_base_type) ? "'" . $this->db->escape($this->price_base_type) . "'" : "null") . ","; $sql .= " default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " tva_tx=" . (isset($this->tva_tx) ? $this->tva_tx : "null") . ","; + $sql .= " tva_tx=" . (isset($this->tva_tx) ? (empty($this->tva_tx)?0:$this->tva_tx) : "null") . ","; $sql .= " recuperableonly=" . (isset($this->recuperableonly) ? $this->recuperableonly : "null") . ","; - $sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? $this->localtax1_tx : "null") . ","; - $sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? $this->localtax2_tx : "null") . ","; + $sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? (empty($this->localtax1_tx)?0:$this->localtax1_tx) : "null") . ","; + $sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? (empty($this->localtax2_tx)?0:$this->localtax2_tx) : "null") . ","; $sql .= " localtax1_type=" . (! empty($this->localtax1_type) ? "'".$this->localtax1_type."'": "'0'") . ","; $sql .= " localtax2_type=" . (! empty($this->localtax2_type) ? "'".$this->localtax2_type."'": "'0'") . ","; $sql .= " fk_user=" . $user->id . ","; From 947acfffe204575feeee6eb5bb38cd88bd09424a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Aug 2017 16:53:29 +0200 Subject: [PATCH 2/9] FIX #7173 --- htdocs/adherents/subscription.php | 52 +++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 0c9c8467f1f..c7904667846 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -113,7 +113,6 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights if ($result < 0) { $langs->load("errors"); - $errmsg=$langs->trans($company->error); setEventMessages($company->error, $company->errors, 'errors'); } else @@ -123,7 +122,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights } else { - $errmsg=$object->error; + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -211,7 +210,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); } - $subscription=$_POST["subscription"]; // Amount of subscription + $subscription=price2num(GETPOST("subscription",'alpha')); // Amount of subscription $label=$_POST["label"]; // Payment informations @@ -229,6 +228,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $error++; $langs->load("errors"); $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateSubscription")); + setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } if (GETPOST('end') && ! $datesubend) @@ -236,6 +236,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $error++; $langs->load("errors"); $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateEndSubscription")); + setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } if (! $datesubend) @@ -246,16 +247,20 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $error++; $errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); + setEventMessages($errmsg, null, 'errors'); $action='addsubscription'; } + $amount = price2num(GETPOST("subscription",'alpha')); + // Check if a payment is mandatory or not if (! $error && $adht->subscription) // Member type need subscriptions { - if (! is_numeric($_POST["subscription"])) + if (! is_numeric($amount)) { // If field is '' or not a numeric value $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")); + setEventMessages($errmsg, null, 'errors'); $error++; $action='addsubscription'; } @@ -273,7 +278,11 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { if ($_POST["accountid"]) $errmsg=$langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); } - if ($errmsg) $action='addsubscription'; + if ($errmsg) + { + setEventMessages($errmsg, null, 'errors'); + $action='addsubscription'; + } } } } @@ -319,6 +328,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $error++; $errmsg=$db->lasterror(); + setEventMessages($errmsg, null, 'errors'); } } else @@ -326,14 +336,16 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $error++; $errmsg=$acct->error; $errmsgs=$acct->errors; - } + setEventMessages($errmsg, $errmsgs, 'errors'); + } } else { $error++; $errmsg=$acct->error; $errmsgs=$acct->errors; - } + setEventMessages($errmsg, $errmsgs, 'errors'); + } } // If option choosed, we create invoice @@ -351,6 +363,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $langs->load("errors"); $errmsg=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); + setEventMessages($errmsg, null, 'errors'); $error++; } } @@ -361,6 +374,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $errmsg=$customer->error; $errmsgs=$acct->errors; + setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } @@ -378,6 +392,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $error++; $errmsg='ErrorNoPaymentTermRECEPFound'; + setEventMessages($errmsg, null, 'errors'); } } $invoice->socid=$object->fk_soc; @@ -389,12 +404,13 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']); } - + $result=$invoice->create($user); if ($result <= 0) { $errmsg=$invoice->error; $errmsgs=$invoice->errors; + setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } @@ -415,6 +431,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if ($result <= 0) { $errmsg=$invoice->error; + setEventMessages($errmsg, null, 'errors'); $error++; } } @@ -427,6 +444,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $errmsg=$invoice->error; $errmsgs=$invoice->errors; + setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } @@ -454,6 +472,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $errmsg=$paiement->error; $errmsgs=$paiement->errors; + setEventMessages($errmsg, $errmsgs, 'errors'); $error++; } } @@ -535,6 +554,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if ($result < 0) { $errmsg=$object->error; + setEventMessages($errmsg, null, 'errors'); } } @@ -581,12 +601,12 @@ if ($rowid > 0) dol_fiche_head($head, 'subscription', $langs->trans("Member"), 0, 'user'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'rowid', $linkback); - + print '
'; print '
'; - + print '
'; print ''; @@ -624,13 +644,13 @@ if ($rowid > 0) } print '
'; - + print '
'; print '
'; - + print '
'; print ''; - + // Birthday print ''; @@ -677,7 +697,7 @@ if ($rowid > 0) } } print ''; - + // Third party Dolibarr if (! empty($conf->societe->enabled)) { @@ -752,7 +772,7 @@ if ($rowid > 0) print "\n"; print '
'; - + dol_fiche_end(); print ''; From 1b1d1a8d0b093f0bc34d717acce479048afea69e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Aug 2017 16:57:07 +0200 Subject: [PATCH 3/9] FIX #7156 --- htdocs/societe/soc.php | 55 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b9c962a5168..06846d34203 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -140,7 +140,7 @@ if (empty($reshook)) if (!$errors) { // TODO Move the merge function into class of object. - + $db->begin(); // Recopy some data @@ -157,26 +157,29 @@ if (empty($reshook)) { if (empty($object->$property)) $object->$property = $soc_origin->$property; } - + // Concat some data $listofproperties=array( - 'note_public', 'note_private' + 'note_public', 'note_private' ); foreach ($listofproperties as $property) { $object->$property = dol_concatdesc($object->$property, $soc_origin->$property); } - + // Merge extrafields - foreach ($soc_origin->array_options as $key => $val) + if (is_array($soc_origin->array_options)) { - if (empty($object->array_options[$key])) $object->array_options[$key] = $val; + foreach ($soc_origin->array_options as $key => $val) + { + if (empty($object->array_options[$key])) $object->array_options[$key] = $val; + } } // TODO Merge categories $object->update($object->id, $user); - - // Move links + + // Move links $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', 'Societe' => '/societe/class/societe.class.php', @@ -487,7 +490,7 @@ if (empty($reshook)) if (empty($object->fournisseur)) $object->code_fournisseur=''; $result = $object->create($user); - + if ($result >= 0) { if ($object->particulier) @@ -557,7 +560,7 @@ if (empty($reshook)) $object->code_fournisseur = null; $object->code_client = null; } - + $error=$object->error; $errors=$object->errors; } @@ -852,7 +855,7 @@ else $object->particulier = $private; $object->prefix_comm = GETPOST('prefix_comm'); $object->client = GETPOST('client')?GETPOST('client'):$object->client; - + if(empty($duplicate_code_error)) { $object->code_client = GETPOST('code_client', 'alpha'); $object->fournisseur = GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur; @@ -860,7 +863,7 @@ else else { setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'),'', 'warnings'); } - + $object->code_fournisseur = GETPOST('code_fournisseur', 'alpha'); $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); @@ -1136,7 +1139,7 @@ else print ''; print ''; print ''; - + // Skype if (! empty($conf->skype->enabled)) { @@ -1216,7 +1219,7 @@ else print ''; - + } elseif($mysoc->localtax1_assuj=="1") { @@ -1230,7 +1233,7 @@ else print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1); print ''; } - + // Type - Size print ''; - + } elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") { @@ -1774,7 +1777,7 @@ else print ''; } print ''; - + } elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") { @@ -1788,7 +1791,7 @@ else } print ''; } - + // VAT Code print ''; print ''; - + if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) { print ''; @@ -2144,7 +2147,7 @@ else print ''; } print ''; - + } } elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") @@ -2154,7 +2157,7 @@ else print ''; if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) { - + print ''; print ''; print ''; @@ -2167,7 +2170,7 @@ else print ''; } print ''; - + } } /* @@ -2178,7 +2181,7 @@ else print ''; } */ - + // VAT Code print ''; print '
'.$langs->trans("Birthday").''.dol_print_date($object->birth,'day').'
'.fieldLabel('Web','url').'
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1); print '
'.fieldLabel('ThirdPartyType','typent_id').''."\n"; $sortparam=(empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. @@ -1751,7 +1754,7 @@ else $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); print ''; } - + print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if (! isOnlyOneLocalTax(2)) @@ -1761,7 +1764,7 @@ else print ''; } print '
'.fieldLabel('VATIntra','intra_vat').''; @@ -2090,7 +2093,7 @@ else print '
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print yn($object->localtax2_assuj); print '
'.$object->localtax1_value.'
'.$object->localtax2_value.'
'.$langs->trans('VATIntra').''; @@ -2573,10 +2576,10 @@ else // Subsidiaries list if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) - { + { $result=show_subsidiaries($conf,$langs,$db,$object); } - + // Contacts list if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { From 9079d2890c429ac8012a70a3546f238d1330e1b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Aug 2017 18:13:42 +0200 Subject: [PATCH 4/9] Fix ajout du code devise Franc Pacifique --- htdocs/install/mysql/data/llx_c_currencies.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_c_currencies.sql b/htdocs/install/mysql/data/llx_c_currencies.sql index d9b1390bb32..cb34f60291f 100644 --- a/htdocs/install/mysql/data/llx_c_currencies.sql +++ b/htdocs/install/mysql/data/llx_c_currencies.sql @@ -154,7 +154,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'VEF' INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'VND', '[8363]', 1, 'Viet Nam Dong'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'XAF', NULL, 1, 'Communaute Financiere Africaine (BEAC) CFA Franc'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'XOF', NULL, 1, 'Communaute Financiere Africaine (BCEAO) Franc'); -INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'XPF', NULL, 1, 'Franc pacifique (XPF)'); +INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'XPF', '[70]', 1, 'Franc pacifique (XPF)'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'YER', '[65020]', 1, 'Yemen Rial'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'ZWD', '[90,36]', 1, 'Zimbabwe Dollar'); From ccb5344d32b803dd8abb02d27e2888f856f24612 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Aug 2017 18:52:03 +0200 Subject: [PATCH 5/9] Fix links --- htdocs/core/boxes/box_activity.php | 494 +++++++++--------- .../install/mysql/data/llx_c_currencies.sql | 2 +- 2 files changed, 248 insertions(+), 248 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index ae3e270101e..02b1d1880c8 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -97,181 +97,95 @@ class box_activity extends ModeleBoxes $cumuldata = array(); - // list the summary of the bills - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) + + // list the summary of the propals + if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $facturestatic=new Facture($db); + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $propalstatic=new Propal($db); - // part 1 - $cachedir = DOL_DATA_ROOT.'/facture/temp'; - $filename = '/boxactivity-invoice'.$fileid; + $cachedir = DOL_DATA_ROOT.'/propale/temp'; + $filename = '/boxactivity-propal'.$fileid; + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); + if ($refresh) + { + $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; + $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= ")"; + $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " AND p.fk_soc = s.rowid"; + 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 p.datep >= '".$db->idate($tmpdate)."'"; + $sql.= " AND p.date_cloture IS NULL"; // just unclosed + $sql.= " GROUP BY p.fk_statut"; + $sql.= " ORDER BY p.fk_statut DESC"; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $data = array(); - 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"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE f.entity = ".$conf->entity; - 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"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $j=0; - while ($j < $num) { - $data[$j]=$db->fetch_object($result); - $j++; - } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $db->free($result); - } else { - dol_print_error($db); - } - } else { - $data = dol_readcachefile($cachedir, $filename); - } + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $db->free($result); + } else { + dol_print_error($db); + } + } + else + { + $data = dol_readcachefile($cachedir, $filename); + } - $cumuldata=array_merge($cumuldata, $data); - if (! empty($data)) { - $j=0; - while ($line < count($cumuldata)) { - $billurl="viewstatut=2&paye=1&year=".$data[$j]->annee; - $this->info_box_contents[$line][0] = array( - 'td' => 'align="left" width="16"', - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - 'logo' => 'bill', - ); + $cumuldata=array_merge($cumuldata, $data); + if (! empty($data)) + { + $j=0; + while ($line < count($cumuldata)) + { + $this->info_box_contents[$line][0] = array( + 'td' => 'align="left" width="16"', + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, + 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), + 'logo' => 'object_propal' + ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1,$data[$j]->fk_statut,0)." ".$data[$j]->annee, - ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), + ); - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), - 'text' => $data[$j]->nb, - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - ); + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, + ); + $totalnb += $data[$j]->nb; - $this->info_box_contents[$line][3] = array( - 'td' => 'class="right"', - 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency) - ); + $this->info_box_contents[$line][3] = array( + 'td' => 'class="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), + ); + $totalMnt += $data[$j]->Mnttot; + $this->info_box_contents[$line][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3), + ); - // We add only for the current year - if ($data[$j]->annee == date("Y")) { - $totalnb += $data[$j]->nb; - $totalMnt += $data[$j]->Mnttot; - } - $this->info_box_contents[$line][4] = array( - 'td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3), - ); - $line++; - $j++; - } - if (count($data)==0) - $this->info_box_contents[$line][0] = array( - 'td' => 'align="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); - } - - // part 2 - $cachedir = DOL_DATA_ROOT.'/facture/temp'; - $filename = '/boxactivity-invoice2'.$fileid; - - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - - 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 = ".$conf->entity; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND paye=0"; - $sql.= " GROUP BY f.fk_statut"; - $sql.= " ORDER BY f.fk_statut DESC"; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $j=0; - while ($j < $num) { - $data[$j]=$db->fetch_object($result); - $j++; - } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $db->free($result); - } else { - dol_print_error($db); - } - } else { - $data = dol_readcachefile($cachedir, $filename); - } - - $cumuldata=array_merge($cumuldata, $data); - if (! empty($data)) { - $j=0; - - while ($line < count($cumuldata)) { - $billurl="viewstatut=".$data[$j]->fk_statut."&paye=0"; - $this->info_box_contents[$line][0] = array( - 'td' => 'align="left" width="16"', - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - 'logo' => 'bill', - ); - - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), - ); - - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'text' => $data[$j]->nb, - 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", - ); - $totalnb += $data[$j]->nb; - $this->info_box_contents[$line][3] = array( - 'td' => 'class="right"', - 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), - ); - $totalMnt += $objp->Mnttot; - $this->info_box_contents[$line][4] = array( - 'td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3), - ); - $line++; - $j++; - } - if ($num==0) - $this->info_box_contents[$line][0] = array( - 'td' => 'align="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), - ); - } + $line++; + $j++; + } + } } // list the summary of the orders @@ -295,12 +209,10 @@ class box_activity extends ModeleBoxes 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 c.date_commande >= '".$db->idate($tmpdate)."'"; - $sql.= " AND c.facture=0"; $sql.= " GROUP BY c.fk_statut"; $sql.= " ORDER BY c.fk_statut DESC"; $result = $db->query($sql); - if ($result) { $num = $db->num_rows($result); $j=0; @@ -359,94 +271,182 @@ class box_activity extends ModeleBoxes } } - // list the summary of the propals - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) + + // list the summary of the bills + if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $propalstatic=new Propal($db); + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $facturestatic=new Facture($db); - $cachedir = DOL_DATA_ROOT.'/propale/temp'; - $filename = '/boxactivity-propal'.$fileid; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $data = array(); - if ($refresh) - { - $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ")"; - $sql.= " WHERE p.entity = ".$conf->entity; - $sql.= " AND p.fk_soc = s.rowid"; - 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 p.datep >= '".$db->idate($tmpdate)."'"; - $sql.= " AND p.date_cloture IS NULL"; // just unclosed - $sql.= " GROUP BY p.fk_statut"; - $sql.= " ORDER BY p.fk_statut DESC"; + // part 1 + $cachedir = DOL_DATA_ROOT.'/facture/temp'; + $filename = '/boxactivity-invoice'.$fileid; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); + 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"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= ")"; + $sql.= " WHERE f.entity = ".$conf->entity; + 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"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; + $sql.= " GROUP BY f.fk_statut"; + $sql.= " ORDER BY f.fk_statut DESC"; - $j=0; - while ($j < $num) { - $data[$j]=$db->fetch_object($result); - $j++; - } - if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $data); - } - $db->free($result); - } else { - dol_print_error($db); - } - } - else - { - $data = dol_readcachefile($cachedir, $filename); - } + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $db->free($result); + } else { + dol_print_error($db); + } + } else { + $data = dol_readcachefile($cachedir, $filename); + } - $cumuldata=array_merge($cumuldata, $data); - if (! empty($data)) - { - $j=0; - while ($line < count($cumuldata)) - { - $this->info_box_contents[$line][0] = array( - 'td' => 'align="left" width="16"', - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, - 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), - 'logo' => 'object_propal' - ); + $cumuldata=array_merge($cumuldata, $data); + if (! empty($data)) { + $j=0; + while ($line < count($cumuldata)) { + $billurl="search_status=2&paye=1&year=".$data[$j]->annee; + $this->info_box_contents[$line][0] = array( + 'td' => 'align="left" width="16"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'logo' => 'bill', + ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), - ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1,$data[$j]->fk_statut,0)." ".$data[$j]->annee, + ); - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right"', - 'text' => $data[$j]->nb, - 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut,0), - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=".$data[$j]->fk_statut, - ); - $totalnb += $data[$j]->nb; + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1,$data[$j]->fk_statut,0), + 'text' => $data[$j]->nb, + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + ); - $this->info_box_contents[$line][3] = array( - 'td' => 'class="right"', - 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), - ); - $totalMnt += $data[$j]->Mnttot; - $this->info_box_contents[$line][4] = array( - 'td' => 'align="right" width="18"', - 'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3), - ); + $this->info_box_contents[$line][3] = array( + 'td' => 'class="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency) + ); - $line++; - $j++; - } - } + // We add only for the current year + if ($data[$j]->annee == date("Y")) { + $totalnb += $data[$j]->nb; + $totalMnt += $data[$j]->Mnttot; + } + $this->info_box_contents[$line][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3), + ); + $line++; + $j++; + } + if (count($data)==0) + $this->info_box_contents[$line][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); + } + + // part 2 + $cachedir = DOL_DATA_ROOT.'/facture/temp'; + $filename = '/boxactivity-invoice2'.$fileid; + + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + + 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 = ".$conf->entity; + $sql.= " AND f.fk_soc = s.rowid"; + $sql.= " AND paye=0"; + $sql.= " GROUP BY f.fk_statut"; + $sql.= " ORDER BY f.fk_statut DESC"; + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $j=0; + while ($j < $num) { + $data[$j]=$db->fetch_object($result); + $j++; + } + if (! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $data); + } + $db->free($result); + } else { + dol_print_error($db); + } + } else { + $data = dol_readcachefile($cachedir, $filename); + } + + $cumuldata=array_merge($cumuldata, $data); + if (! empty($data)) { + $j=0; + + while ($line < count($cumuldata)) { + $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; + $this->info_box_contents[$line][0] = array( + 'td' => 'align="left" width="16"', + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'logo' => 'bill', + ); + + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), + ); + + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right"', + 'text' => $data[$j]->nb, + 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0,$data[$j]->fk_statut,0), + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + ); + $totalnb += $data[$j]->nb; + $this->info_box_contents[$line][3] = array( + 'td' => 'class="right"', + 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), + ); + $totalMnt += $objp->Mnttot; + $this->info_box_contents[$line][4] = array( + 'td' => 'align="right" width="18"', + 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3), + ); + $line++; + $j++; + } + if ($num==0) + $this->info_box_contents[$line][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), + ); + } } // Add the sum in the bottom of the boxes diff --git a/htdocs/install/mysql/data/llx_c_currencies.sql b/htdocs/install/mysql/data/llx_c_currencies.sql index cb34f60291f..db1ba19aa6e 100644 --- a/htdocs/install/mysql/data/llx_c_currencies.sql +++ b/htdocs/install/mysql/data/llx_c_currencies.sql @@ -154,7 +154,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'VEF' INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'VND', '[8363]', 1, 'Viet Nam Dong'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'XAF', NULL, 1, 'Communaute Financiere Africaine (BEAC) CFA Franc'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'XOF', NULL, 1, 'Communaute Financiere Africaine (BCEAO) Franc'); -INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'XPF', '[70]', 1, 'Franc pacifique (XPF)'); +INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'XPF', '[70]', 1, 'Franc CFP'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'YER', '[65020]', 1, 'Yemen Rial'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'ZWD', '[90,36]', 1, 'Zimbabwe Dollar'); From ab37794f616a4f8df4a5a5ba5d6b308b55015b1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Aug 2017 19:34:26 +0200 Subject: [PATCH 6/9] Fix text --- htdocs/core/class/html.formmail.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index f2e861ea932..4ec9c91aa80 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -473,7 +473,7 @@ class FormMail extends Form $out.= ' <'.$this->tomail.'>'; if ($this->withtofree) { - $out.= '
'.$langs->trans("or").' withto) :"").'" />'; + $out.= '
'.$langs->trans("and").' withto) :"").'" />'; } } else @@ -489,7 +489,7 @@ class FormMail extends Form } if (! empty($this->withto) && is_array($this->withto)) { - if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; + if (! empty($this->withtofree)) $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withto; foreach($tmparray as $key => $val) @@ -522,7 +522,7 @@ class FormMail extends Form $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; if (! empty($this->withtocc) && is_array($this->withtocc)) { - $out.= " ".$langs->trans("or")." "; + $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtocc; foreach($tmparray as $key => $val) @@ -551,7 +551,7 @@ class FormMail extends Form $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; if (! empty($this->withtoccc) && is_array($this->withtoccc)) { - $out.= " ".$langs->trans("or")." "; + $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtoccc; foreach($tmparray as $key => $val) From 326d3df63f2a0b9151c1b303f2807607a8acd3a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Aug 2017 13:23:15 +0200 Subject: [PATCH 7/9] FIX select of category FIX pb with extrafield list and key '0' Conflicts: htdocs/core/class/extrafields.class.php --- htdocs/core/class/commonobject.class.php | 12 +++++ htdocs/core/class/extrafields.class.php | 4 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- htdocs/install/mysql/migration/repair.sql | 3 +- htdocs/langs/en_US/admin.lang | 10 ++--- .../modulebuilder/template/myobject_list.php | 2 +- htdocs/societe/list.php | 45 +++++++++++-------- 8 files changed, 50 insertions(+), 30 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8f618e2fbf0..a79f01d6ed8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4297,6 +4297,12 @@ abstract class CommonObject $this->array_options[$key] = null; } break; + /*case 'select': // Not required, we chosed value='0' for undefined values + if ($value=='-1') + { + $this->array_options[$key] = null; + } + break;*/ case 'price': $this->array_options[$key] = price2num($this->array_options[$key]); break; @@ -4430,6 +4436,12 @@ abstract class CommonObject $this->array_options["options_".$key] = null; } break; + /*case 'select': // Not required, we chosed value='0' for undefined values + if ($value=='-1') + { + $this->array_options[$key] = null; + } + break;*/ case 'price': $this->array_options["options_".$key] = price2num($this->array_options["options_".$key]); break; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index e44fa8a5aec..a01f97431ef 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -882,10 +882,10 @@ class ExtraFields $out.=''; foreach ($param['options'] as $key => $val) { - if ($key == '') continue; + if ((string) $key == '') continue; list($val, $parent) = explode('|', $val); $out.='