From cf857b712ab38ad19d51fc9a0112b85319136c78 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 14 Jun 2015 12:29:47 +0200 Subject: [PATCH 01/14] Fix: select date problem with mobile device (#3039) --- htdocs/compta/bank/virement.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php index 9bf4fd9ea2e..66a61850ee8 100644 --- a/htdocs/compta/bank/virement.php +++ b/htdocs/compta/bank/virement.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur - * Copytight (C) 2005-2009 Regis Houssin + * Copytight (C) 2005-2015 Regis Houssin * Copytight (C) 2012 Juanjo Menent * Copyright (C) 2015 Marcos GarcĂ­a * @@ -180,7 +180,7 @@ print $form->select_comptes($account_to,'account_to',0,'',1); print "\n"; print ""; -$form->select_date($dateo,'','','','','add'); +$form->select_date((! empty($dateo)?$dateo:''),'','','','','add'); print "\n"; print ''; print ''; From 05cb1f7ba753af3681983832efbc64f98f7685cb Mon Sep 17 00:00:00 2001 From: fmarcet Date: Tue, 16 Jun 2015 16:59:48 +0200 Subject: [PATCH 02/14] Fix: Date filter on customer orders --- htdocs/societe/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index d7c8616a273..8512b9b0d12 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -180,7 +180,7 @@ if ($type_element == 'order') $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; $where.= " AND d.fk_commande = c.rowid"; $where.= " AND c.entity = ".$conf->entity; - $datePrint = 'c.datef'; + $datePrint = 'c.date_commande'; $doc_number='c.ref'; $thirdTypeSelect='customer'; } From 06962cb4e6de35ac7ffde6b239347ebe887c71b2 Mon Sep 17 00:00:00 2001 From: phf Date: Tue, 23 Jun 2015 16:26:05 +0200 Subject: [PATCH 03/14] FIX : tool export handle the type "select" extrafields and return the value instead of id --- htdocs/core/modules/export/export_csv.modules.php | 7 +++++++ htdocs/core/modules/export/export_excel.modules.php | 9 ++++++++- htdocs/core/modules/export/export_tsv.modules.php | 9 ++++++++- htdocs/core/modules/modSociete.class.php | 3 +++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index ce058a93455..58f4f036d5e 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -252,6 +252,13 @@ class ExportCsv extends ModeleExports $newvalue=$this->csv_clean($newvalue,$outputlangs->charset_output); + if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7)) + { + $array = unserialize($typefield); + $array = $array['options']; + $newvalue = $array[$newvalue]; + } + fwrite($this->handle,$newvalue.$this->separator); $this->col++; } diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index 46ab465f42e..6cad56f07bb 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -305,7 +305,14 @@ class ExportExcel extends ModeleExports $newvalue=$this->excel_clean($newvalue); $typefield=isset($array_types[$code])?$array_types[$code]:''; - + + if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7)) + { + $array = unserialize($typefield); + $array = $array['options']; + $newvalue = $array[$newvalue]; + } + // Traduction newvalue if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) { diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index 409102fd857..a077cc1772e 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -226,7 +226,14 @@ class ExportTsv extends ModeleExports if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]); $newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output); - + + if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7)) + { + $array = unserialize($typefield); + $array = $array['options']; + $newvalue = $array[$newvalue]; + } + fwrite($this->handle,$newvalue.$this->separator); $this->col++; } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 4367aae3789..ea77a39e21b 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -355,6 +355,9 @@ class modSociete extends DolibarrModules case 'sellist': $typeFilter="List:".$obj->param; break; + case 'select': + $typeFilter="Select:".$obj->param; + break; } $this->export_fields_array[$r][$fieldname]=$fieldlabel; $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; From 582f9cd214b49a0124ce37e0688fc84a1f3cfce0 Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 26 Jun 2015 11:04:08 +0200 Subject: [PATCH 04/14] FIX : keep filter by category or by not enough stock if we switch page --- htdocs/product/reassort.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index e824cd06b13..35e7044157f 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -194,11 +194,11 @@ if ($resql) if ($sref || $snom || $sall || GETPOST('search')) { - print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy.(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num); } else { - print_barre_liste($texte, $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":"").(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num); } if (! empty($catid)) @@ -342,11 +342,11 @@ if ($resql) { if ($sref || $snom || $sall || GETPOST('search')) { - print_barre_liste('', $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, ''); + print_barre_liste('', $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy.(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num, 0, ''); } else { - print_barre_liste('', $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":"")."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, ''); + print_barre_liste('', $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":"")."&tosell=".$tosell."&tobuy=".$tobuy.(!empty($search_categ) ? '&search_categ='.$search_categ : '').(!empty($toolowstock) ? '&toolowstock='.$toolowstock : ''), $sortfield, $sortorder,'',$num, 0, ''); } } From ee643ed2a72b6ea648b15f058a9d6a6c0d3f9cfe Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 2 Jul 2015 14:08:16 +0200 Subject: [PATCH 05/14] Fix : Project list was not keeping parameters on sorts --- htdocs/projet/liste.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/projet/liste.php b/htdocs/projet/liste.php index 39fcdb64a01..857d8949c9d 100644 --- a/htdocs/projet/liste.php +++ b/htdocs/projet/liste.php @@ -119,16 +119,23 @@ if ($resql) if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'

'; else print $langs->trans("ProjectsPublicDesc").'

'; } + + $param=''; + if ($mine) $param.='mode=mine'; + if ($socid) $param.='&socid='.$socid; + if ($search_ref) $param.='&search_ref='.$search_ref; + if ($search_label) $param.='&search_label='.$search_label; + if ($search_societe) $param.='&search_societe='.$search_societe; print '
'; print ''; print ''; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.ref","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"p.title","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Visibility"),$_SERVER["PHP_SELF"],"p.public","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],'p.fk_statut',"","",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Visibility"),$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],'p.fk_statut',"",$param,'align="right"',$sortfield,$sortorder); print "\n"; print ''; From c87328b362ec6624ddaa8fc7e914c09d7d5bcf79 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 2 Jul 2015 17:00:37 +0200 Subject: [PATCH 06/14] FIX : contact country had wrong display if the country dont have translate --- htdocs/contact/class/contact.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index a5c3764fd28..fc6d8ee7ad1 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -555,7 +555,7 @@ class Contact extends CommonObject $this->country_id = $obj->country_id; $this->country_code = $obj->country_id?$obj->country_code:''; - $this->country = ($obj->country_id > 0)?$langs->transnoentitiesnoconv("Country".$obj->country_code):''; + $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; $this->socid = $obj->fk_soc; $this->socname = $obj->socname; From 5d14d05ce11870e474172fba10198addd7871aa7 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 3 Jul 2015 16:38:54 +0200 Subject: [PATCH 07/14] Fix : Social contribution payment deletion was not deleting the bank line --- htdocs/compta/bank/class/account.class.php | 2 +- .../class/paymentsocialcontribution.class.php | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 8bcabf7f17b..6d1e417f4ea 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1152,7 +1152,7 @@ class AccountLine extends CommonObject if ($this->rappro) { // Protection to avoid any delete of consolidated lines - $this->error="DeleteNotPossibleLineIsConsolidated"; + $this->error="ErrorDeleteNotPossibleLineIsConsolidated"; return -1; } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index e89f2a273f8..a2640bcbc9c 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -313,17 +313,20 @@ class PaymentSocialContribution extends CommonObject { global $conf, $langs; $error=0; + + dol_syslog(get_class($this)."::delete"); $this->db->begin(); - if (! $error) + if ($this->bank_line > 0) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql.= " WHERE type='payment_sc' AND url_id=".$this->id; - - dol_syslog(get_class($this)."::delete sql=".$sql); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $accline = new AccountLine($this->db); + $accline->fetch($this->bank_line); + $result = $accline->delete(); + if($result < 0) { + $this->errors[] = $accline->error; + $error++; + } } if (! $error) From 9e7cb70d63a5fcdcb9b073ec011f3b4af8b12c09 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 8 Jul 2015 16:03:15 +0200 Subject: [PATCH 08/14] Fix: missing shared parameters --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 03d044a2ee6..7111b2387bd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -69,8 +69,8 @@ abstract class CommonObject $sql = "SELECT rowid, ref, ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX.$element; - $sql.= " WHERE entity IN (".getEntity($element).")" ; - + $sql.= " WHERE entity IN (".getEntity($element, true).")" ; + if ($id > 0) $sql.= " AND rowid = ".$db->escape($id); else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'"; else if ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'"; From 20bdfdb2865f80c8b658db6a6ebfedbdb5687128 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 2 Jul 2015 13:37:26 +0200 Subject: [PATCH 09/14] Fix : withdrawal rejection were taking the total amount of the invoice instead of the amount of the withdrawal --- .../class/rejetprelevement.class.php | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 77bafae3603..aae942468dd 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -87,7 +87,7 @@ class RejetPrelevement dol_syslog("RejetPrelevement::Create id $id"); $bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT; - $facs = $this->getListInvoices(); + $facs = $this->getListInvoices(1); $this->db->begin(); @@ -132,7 +132,7 @@ class RejetPrelevement for ($i = 0; $i < $num; $i++) { $fac = new Facture($this->db); - $fac->fetch($facs[$i]); + $fac->fetch($facs[$i][0]); // Make a negative payment $pai = new Paiement($this->db); @@ -144,7 +144,7 @@ class RejetPrelevement * PHP installs sends only the part integer negative */ - $pai->amounts[$facs[$i]] = price2num($fac->total_ttc * -1); + $pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * -1); $pai->datepaye = $date_rejet; $pai->paiementid = 3; // type of payment: withdrawal $pai->num_paiement = $fac->ref; @@ -152,7 +152,7 @@ class RejetPrelevement if ($pai->create($this->user) < 0) // we call with no_commit { $error++; - dol_syslog("RejetPrelevement::Create Error creation payment invoice ".$facs[$i]); + dol_syslog("RejetPrelevement::Create Error creation payment invoice ".$facs[$i][0]); } else { @@ -269,22 +269,24 @@ class RejetPrelevement } /** - * Retrieve the list of invoices + * Retrieve the list of invoices + * @param int $amounts If you want to get the amount of the order for each invoice * - * @return void + * @return Array List of invoices related to the withdrawal line + * @TODO A withdrawal line is today linked to one and only one invoice. So the function should return only one object ? */ - private function getListInvoices() + private function getListInvoices($amounts=0) { global $conf; $arr = array(); //Returns all invoices of a withdrawal - $sql = "SELECT f.rowid as facid"; + $sql = "SELECT f.rowid as facid, pl.amount"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_lignes as pl ON (pf.fk_prelevement_lignes = pl.rowid)"; $sql.= " WHERE pf.fk_prelevement_lignes = ".$this->id; - $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.entity = ".$conf->entity; $resql=$this->db->query($sql); @@ -298,7 +300,14 @@ class RejetPrelevement while ($i < $num) { $row = $this->db->fetch_row($resql); - $arr[$i] = $row[0]; + if (!$amounts) $arr[$i] = $row[0]; + else + { + $arr[$i] = array( + $row[0], + $row[1] + ); + } $i++; } } From e9d1e6265d0a15377629baf66fe9dd57046c517d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 18 Jul 2015 14:25:05 +0200 Subject: [PATCH 10/14] Fix: [ bug #2696 ] Adding complementary attribute fails if code is numerics Close #2696 --- ChangeLog | 1 + htdocs/core/actions_extrafields.inc.php | 2 +- htdocs/langs/en_US/errors.lang | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f822d08771..22325dd9df8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,7 @@ English Dolibarr ChangeLog - Fix: [ bug #2542 ] Contracts store localtax preferences - Fix: Bad permission assignments for stock movements actions - Fix: [ bug #2891 ] Category hooks do not work +- Fix: [ bug #2696 ] Adding complementary attribute fails if code is numerics ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 89edfcbae8e..d547d635855 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -118,7 +118,7 @@ if ($action == 'add') if (! $error) { // attrname must be alphabetical and lower case only - if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname'])) + if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']) && !is_numeric($_POST["attrname"])) { // Construct array for parameter (value of select list) $default_value = GETPOST('default_value'); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 4f5ac8fb9ec..e4e35c2653a 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -65,7 +65,7 @@ ErrorNoValueForCheckBoxType=Please fill value for checkbox list ErrorNoValueForRadioType=Please fill value for radio list ErrorBadFormatValueList=The list value cannot have more than one come : %s, but need at least one: llave,valores ErrorFieldCanNotContainSpecialCharacters=Field %s must not contains special characters. -ErrorFieldCanNotContainSpecialNorUpperCharacters=Field %s must not contains special characters, nor upper case characters. +ErrorFieldCanNotContainSpecialNorUpperCharacters=Field %s must not contain special characters, nor upper case characters and cannot contain only numbers. ErrorNoAccountancyModuleLoaded=No accountancy module activated ErrorExportDuplicateProfil=This profile name already exists for this export set. ErrorLDAPSetupNotComplete=Dolibarr-LDAP matching is not complete. From 7185cfeb8424f4785df8f8c9abc5820c2e2a59bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 18 Jul 2015 14:48:59 +0200 Subject: [PATCH 11/14] Fix: [ bug #2715 ] Statistics page has broken layout with long thirdparty names --- ChangeLog | 1 + htdocs/compta/facture/stats/index.php | 9 ++++++++- htdocs/core/class/html.form.class.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab5fa93f635..67920bbfee3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,7 @@ Fix: [ bug #2861 ] Undefined variable $res when migrating Fix: [ bug #2837 ] Product list table column header does not match column body Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order Fix: [ bug #2814 ] JPEG photos are not displayed in Product photos page +Fix: [ bug #2715 ] Statistics page has broken layout with long thirdparty names ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 51747fe04d2..08c3750d0e4 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -217,6 +217,13 @@ complete_head_from_modules($conf,$langs,null,$head,$h,$type); dol_fiche_head($head,'byyear',$langs->trans("Statistics")); +$tmp_companies = $form->select_thirdparty_list($socid,'socid',$filter,1, 0, 0, array(), '', 1); +//Array passed as an argument to Form::selectarray to build a proper select input +$companies = array(); + +foreach ($tmp_companies as $value) { + $companies[$value['value']] = $value['label']; +} print '
'; @@ -232,7 +239,7 @@ print '
'; print '
'; // User print ''; - -print '
'.$langs->trans("ThirdParty").''; if ($mode == 'customer') $filter='s.client in (1,2,3)'; if ($mode == 'supplier') $filter='s.fournisseur = 1'; - print $form->select_company($socid,'socid',$filter,1); + print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 100%"'); print '
'.$langs->trans("CreatedBy").''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ce0d8babbc6..289a2d607c3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -836,7 +836,7 @@ class Form $out.= ''; } - array_push($outarray, array('key'=>$obj->rowid, 'value'=>$obj->name, 'label'=>$obj->name)); + array_push($outarray, array('key'=>$obj->rowid, 'value'=>$obj->rowid, 'label'=>$label)); $i++; if (($i % 10) == 0) $out.="\n"; From b28c4df0d690582f038dd72848476976c691d5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 18 Jul 2015 17:35:36 +0200 Subject: [PATCH 12/14] Fix: [ bug #3180 ] formObjectOptions hook when editing thirdparty card does not print result Close #3180 --- ChangeLog | 1 + htdocs/societe/soc.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index ab5fa93f635..1c4034ee0cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,7 @@ Fix: [ bug #2861 ] Undefined variable $res when migrating Fix: [ bug #2837 ] Product list table column header does not match column body Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order Fix: [ bug #2814 ] JPEG photos are not displayed in Product photos page +Fix: [ bug #3180 ] formObjectOptions hook when editing thirdparty card does not print result ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b24179328fc..99e5da3beb8 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -999,6 +999,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); @@ -1407,6 +1408,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); From 3d6c5b09e83f99ccf1466c8143ff47c9fcdf6680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 19 Jul 2015 11:19:47 +0200 Subject: [PATCH 13/14] Fix: [ bug #3268 ] SQL error when accessing thirdparty log page without a socid parameter Close #3268 --- ChangeLog | 1 + htdocs/societe/info.php | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67920bbfee3..3f2bec46f63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ Fix: [ bug #2837 ] Product list table column header does not match column body Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order Fix: [ bug #2814 ] JPEG photos are not displayed in Product photos page Fix: [ bug #2715 ] Statistics page has broken layout with long thirdparty names +Fix: [ bug #3268 ] SQL error when accessing thirdparty log page without a socid parameter ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/societe/info.php b/htdocs/societe/info.php index 8f0d0836ed4..f79b4cf194e 100644 --- a/htdocs/societe/info.php +++ b/htdocs/societe/info.php @@ -60,24 +60,25 @@ $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); $soc = new Societe($db); -$soc->fetch($socid); -$soc->info($socid); +$result = $soc->fetch($socid); -/* - * Affichage onglets - */ -$head = societe_prepare_head($soc); +if ($result > 1) { + $soc->info($socid); -dol_fiche_head($head, 'info', $langs->trans("ThirdParty"),0,'company'); + /* + * Affichage onglets + */ + $head = societe_prepare_head($soc); + + dol_fiche_head($head, 'info', $langs->trans("ThirdParty"), 0, 'company'); + print '
'; + dol_print_object_info($soc); + print '
'; -print '
'; -dol_print_object_info($soc); -print '
'; - -print ''; - + print ''; +} llxFooter(); From 8d7c1f8d4cecaf7e8fada3ed5399fe34bac9c8f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Jul 2015 11:21:21 +0200 Subject: [PATCH 14/14] Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid --- ChangeLog | 1 + htdocs/contact/exportimport.php | 123 ++++++------ htdocs/contact/info.php | 23 ++- htdocs/contact/ldap.php | 284 +++++++++++++------------- htdocs/contact/perso.php | 340 ++++++++++++++++---------------- htdocs/contact/vcard.php | 130 ++++++------ 6 files changed, 456 insertions(+), 445 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67920bbfee3..8d8e9ac9c72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ Fix: [ bug #2837 ] Product list table column header does not match column body Fix: [ bug #2835 ] Customer prices of a product shows incorrect history order Fix: [ bug #2814 ] JPEG photos are not displayed in Product photos page Fix: [ bug #2715 ] Statistics page has broken layout with long thirdparty names +Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/contact/exportimport.php b/htdocs/contact/exportimport.php index 5149eed9efb..c76655f5099 100644 --- a/htdocs/contact/exportimport.php +++ b/htdocs/contact/exportimport.php @@ -33,81 +33,80 @@ $id = GETPOST('id', 'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); +$contact = new Contact($db); + /* * View */ +$form = new Form($db); + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); -$form = new Form($db); - -$contact = new Contact($db); -$contact->fetch($id, $user); - - -$head = contact_prepare_head($contact); - -dol_fiche_head($head, 'exportimport', $title, 0, 'contact'); - - -/* - * Fiche en mode visu - */ -print ''; - -$linkback = ''.$langs->trans("BackToList").''; - -// Ref -print ''; - -// Name -print ''; -print ''; - -// Company -if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) +if ($id > 0) { - if ($contact->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($contact->socid); + $contact->fetch($id, $user); - print ''; - } - else - { - print ''; - } + $head = contact_prepare_head($contact); + + dol_fiche_head($head, 'exportimport', $title, 0, 'contact'); + + + /* + * Fiche en mode visu + */ + print '
'.$langs->trans("Ref").''; -print $form->showrefnav($contact, 'id', $linkback); -print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$contact->lastname.''.$langs->trans("Firstname").''.$contact->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); - print '
'; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Name + print ''; + print ''; + + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($contact->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($contact->socid); + + print ''; + } + else + { + print ''; + } + } + + // Civility + print ''; + + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($contact, 'id', $linkback); + print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$contact->lastname.''.$langs->trans("Firstname").''.$contact->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; + print $contact->getCivilityLabel(); + print '
'; + + print ''; + + print '
'; + + print $langs->trans("ExportCardToFormat").': '; + print ''; + print img_picto($langs->trans("VCard"),'vcard.png').' '; + print $langs->trans("VCard"); + print ''; } -// Civility -print '
'.$langs->trans("UserTitle").''; -print $contact->getCivilityLabel(); -print '
'; - -print ''; - -print '
'; - -print $langs->trans("ExportCardToFormat").': '; -print ''; -print img_picto($langs->trans("VCard"),'vcard.png').' '; -print $langs->trans("VCard"); -print ''; - - - - $db->close(); llxFooter(); -?> diff --git a/htdocs/contact/info.php b/htdocs/contact/info.php index 3ac6747bb6b..5d4904faa87 100644 --- a/htdocs/contact/info.php +++ b/htdocs/contact/info.php @@ -35,6 +35,8 @@ $contactid = GETPOST("id",'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe'); +$contact = new Contact($db); + /* @@ -43,25 +45,26 @@ $result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe'); llxHeader('',$langs->trans("ContactsAddresses"),'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); +if ($contactid > 0) +{ + $result = $contact->fetch($contactid, $user); -$contact = new Contact($db); -$contact->fetch($contactid, $user); -$contact->info($contactid); + $contact->info($contactid); -$head = contact_prepare_head($contact); + $head = contact_prepare_head($contact); -dol_fiche_head($head, 'info', $langs->trans("ContactsAddresses"), 0, 'contact'); + dol_fiche_head($head, 'info', $langs->trans("ContactsAddresses"), 0, 'contact'); -print '
'; -print '
'; + print '
'; + print '
'; -dol_print_object_info($contact); + dol_print_object_info($contact); -print ""; + print ""; +} llxFooter(); $db->close(); -?> diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index f284ee1834d..79e6246fc60 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -40,37 +40,40 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $contact = new Contact($db); -$contact->fetch($id, $user); - -/* - * Actions - */ - -if ($action == 'dolibarr2ldap') +if ($id > 0) { - $message=""; + $contact->fetch($id, $user); - $db->begin(); + /* + * Actions + */ - $ldap=new Ldap(); - $result=$ldap->connect_bind(); - - $info=$contact->_load_ldap_info(); - $dn=$contact->_load_ldap_dn($info); - $olddn=$dn; // We can say that old dn = dn as we force synchro - - $result=$ldap->update($dn,$info,$user,$olddn); - - if ($result >= 0) + if ($action == 'dolibarr2ldap') { - $message.='
'.$langs->trans("ContactSynchronized").'
'; - $db->commit(); - } - else - { - $message.='
'.$ldap->error.'
'; - $db->rollback(); + $message=""; + + $db->begin(); + + $ldap=new Ldap(); + $result=$ldap->connect_bind(); + + $info=$contact->_load_ldap_info(); + $dn=$contact->_load_ldap_dn($info); + $olddn=$dn; // We can say that old dn = dn as we force synchro + + $result=$ldap->update($dn,$info,$user,$olddn); + + if ($result >= 0) + { + $message.='
'.$langs->trans("ContactSynchronized").'
'; + $db->commit(); + } + else + { + $message.='
'.$ldap->error.'
'; + $db->rollback(); + } } } @@ -79,138 +82,139 @@ if ($action == 'dolibarr2ldap') * View */ +$form = new Form($db); + $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); -$form = new Form($db); - -$head = contact_prepare_head($contact); - -dol_fiche_head($head, 'ldap', $title, 0, 'contact'); - - -print ''; - -// Ref -print ''; - -// Name -print ''; -print ''; - -// Company -if ($contact->socid > 0) +if ($id > 0) { - $objsoc = new Societe($db); - $objsoc->fetch($contact->socid); + $head = contact_prepare_head($contact); - print ''; -} -else -{ - print '
'.$langs->trans("Ref").''; -print $form->showrefnav($contact,'id'); -print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$contact->lastname.''.$langs->trans("Firstname").''.$contact->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); + dol_fiche_head($head, 'ldap', $title, 0, 'contact'); + + + print ''; + + // Ref + print ''; -} -// Civility -print ''; + // Name + print ''; + print ''; -// LDAP DN -print '\n"; - -// LDAP Cle -print '\n"; - -// LDAP Server -print '\n"; -print '\n"; -print '\n"; - -print '
'.$langs->trans("Ref").''; + print $form->showrefnav($contact,'id'); print '
'.$langs->trans("UserTitle").''; -print $contact->getCivilityLabel(); -print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$contact->lastname.''.$langs->trans("Firstname").''.$contact->firstname.'
LDAP '.$langs->trans("LDAPContactDn").''.$conf->global->LDAP_CONTACT_DN."
LDAP '.$langs->trans("LDAPNamingAttribute").''.$conf->global->LDAP_KEY_CONTACTS."
LDAP '.$langs->trans("LDAPPrimaryServer").''.$conf->global->LDAP_SERVER_HOST."
LDAP '.$langs->trans("LDAPSecondaryServer").''.$conf->global->LDAP_SERVER_HOST_SLAVE."
LDAP '.$langs->trans("LDAPServerPort").''.$conf->global->LDAP_SERVER_PORT."
'; - -print ''; - - -dol_htmloutput_mesg($message); - - -/* - * Barre d'actions - */ - -print '
'; - -if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') -{ - print ''.$langs->trans("ForceSynchronize").''; -} - -print "
\n"; - -if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print "
\n"; - - - -// Affichage attributs LDAP -print_titre($langs->trans("LDAPInformationsForThisContact")); - -print ''; - -print ''; -print ''; -print ''; -print ''; - -// Lecture LDAP -$ldap=new Ldap(); -$result=$ldap->connect_bind(); -if ($result > 0) -{ - $info=$contact->_load_ldap_info(); - $dn=$contact->_load_ldap_dn($info,1); - $search = "(".$contact->_load_ldap_dn($info,2).")"; - $records=$ldap->getAttribute($dn,$search); - - //var_dump($records); - - // Affichage arbre - if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) + // Company + if ($contact->socid > 0) { - if (! is_array($records)) - { - print ''; - } - else - { - $result=show_ldap_content($records,0,$records['count'],true); - } + $objsoc = new Societe($db); + $objsoc->fetch($contact->socid); + + print ''; } else { - print ''; + print ''; } - $ldap->unbind(); - $ldap->close(); + // Civility + print ''; + + // LDAP DN + print '\n"; + + // LDAP Cle + print '\n"; + + // LDAP Server + print '\n"; + print '\n"; + print '\n"; + + print '
'.$langs->trans("LDAPAttributes").''.$langs->trans("Value").'
'.$langs->trans("ErrorFailedToReadLDAP").'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')
'.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; + print $contact->getCivilityLabel(); + print '
LDAP '.$langs->trans("LDAPContactDn").''.$conf->global->LDAP_CONTACT_DN."
LDAP '.$langs->trans("LDAPNamingAttribute").''.$conf->global->LDAP_KEY_CONTACTS."
LDAP '.$langs->trans("LDAPPrimaryServer").''.$conf->global->LDAP_SERVER_HOST."
LDAP '.$langs->trans("LDAPSecondaryServer").''.$conf->global->LDAP_SERVER_HOST_SLAVE."
LDAP '.$langs->trans("LDAPServerPort").''.$conf->global->LDAP_SERVER_PORT."
'; + + print ''; + + + dol_htmloutput_mesg($message); + + + /* + * Barre d'actions + */ + + print '
'; + + if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') + { + print ''.$langs->trans("ForceSynchronize").''; + } + + print "
\n"; + + if (! empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') print "
\n"; + + + + // Affichage attributs LDAP + print_titre($langs->trans("LDAPInformationsForThisContact")); + + print ''; + + print ''; + print ''; + print ''; + print ''; + + // Lecture LDAP + $ldap=new Ldap(); + $result=$ldap->connect_bind(); + if ($result > 0) + { + $info=$contact->_load_ldap_info(); + $dn=$contact->_load_ldap_dn($info,1); + $search = "(".$contact->_load_ldap_dn($info,2).")"; + $records=$ldap->getAttribute($dn,$search); + + //var_dump($records); + + // Affichage arbre + if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0)) + { + if (! is_array($records)) + { + print ''; + } + else + { + $result=show_ldap_content($records,0,$records['count'],true); + } + } + else + { + print ''; + } + + $ldap->unbind(); + $ldap->close(); + } + else + { + dol_print_error('',$ldap->error); + } + + + print '
'.$langs->trans("LDAPAttributes").''.$langs->trans("Value").'
'.$langs->trans("ErrorFailedToReadLDAP").'
'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')
'; + } -else -{ - dol_print_error('',$ldap->error); -} - - -print '
'; - - $db->close(); llxFooter(); -?> diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 86462d05fae..bd74fc75ef8 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -38,210 +38,213 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); -/* - * Action - */ +$result = $object->fetch($id, $user); -if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) +if ($id > 0) { - $ret = $object->fetch($id); + /* + * Action + */ - // Note: Correct date should be completed with location to have exact GM time of birth. - $object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]); - $object->birthday_alert = $_POST["birthday_alert"]; + if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) + { + // Note: Correct date should be completed with location to have exact GM time of birth. + $object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]); + $object->birthday_alert = $_POST["birthday_alert"]; - $result = $object->update_perso($id, $user); - if ($result > 0) - { - $object->old_name=''; - $object->old_firstname=''; - } - else - { - $error = $object->error; - } + $result = $object->update_perso($id, $user); + if ($result > 0) + { + $object->old_name=''; + $object->old_firstname=''; + } + else + { + $error = $object->error; + } + } } - /* * View */ +$form = new Form($db); + $now=dol_now(); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); -$form = new Form($db); - -$object->fetch($id, $user); - -$head = contact_prepare_head($object); - -dol_fiche_head($head, 'perso', $title, 0, 'contact'); - -if ($action == 'edit') +if ($id > 0) { - /* - * Fiche en mode edition - */ + $head = contact_prepare_head($object); - print ''; - print ''; - print ''; - print ''; + dol_fiche_head($head, 'perso', $title, 0, 'contact'); - print ''; - - // Ref - print ''; - - // Name - print ''; - print ''; - - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + if ($action == 'edit') { - if ($object->socid > 0) + /* + * Fiche en mode edition + */ + + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Ref").''; - print $object->id; - print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'; + + // Ref + print ''; + + // Name + print ''; + print ''; + + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); - print ''; - } - else - { - print ''; - } - } - - // Civility - print ''; - - // Date To Birth - print ''; - - print ''; - } - else - { - print ''; - } - print ''; - - print "
'.$langs->trans("Ref").''; + print $object->id; + print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); - print '
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("DateToBirth").''; - $form=new Form($db); - print $form->select_date($object->birthday,'birthday',0,0,1,"perso"); - print ''.$langs->trans("Alert").': '; - if (! empty($object->birthday_alert)) - { - print '

"; - - print '
'; - print ''; - print '   '; - print ''; - print '
'; - - print "
"; -} -else -{ - /* - * Fiche en mode visu - */ - print ''; - - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - - // Name - print ''; - print ''; - - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($object->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - - print ''; + print ''; + } + else + { + print ''; + } } - else - { - print ''; - } - } + // Civility + print ''; - // Civility - print ''; - - // Date To Birth - print ''; - if (! empty($object->birthday)) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - - print ''; + + print ''; + } + else + { + print ''; + } + print ''; + + print "
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', $linkback); - print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("DateToBirth").''.dol_print_date($object->birthday,"day"); - - print '   '; - //var_dump($birthdatearray); - $ageyear=convertSecondToTime($now-$object->birthday,'year')-1970; - $agemonth=convertSecondToTime($now-$object->birthday,'month')-1; - if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; - else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; - else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; - - - print '   -   '; - if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); - else print $langs->trans("BirthdayAlertOff"); + // Date To Birth + print '
'.$langs->trans("DateToBirth").''; + $form=new Form($db); + print $form->select_date($object->birthday,'birthday',0,0,1,"perso"); print ''.$langs->trans("Alert").': '; + if (! empty($object->birthday_alert)) + { + print '

"; + + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print ""; } else { - print ''.$langs->trans("DateToBirth").''.$langs->trans("Unknown").""; - } - print ""; + /* + * Fiche en mode visu + */ + print ''; - print "
"; + $linkback = ''.$langs->trans("BackToList").''; -} + // Ref + print ''.$langs->trans("Ref").''; + print $form->showrefnav($object, 'id', $linkback); + print ''; -dol_fiche_end(); + // Name + print ''.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''; + print ''.$langs->trans("Firstname").''.$object->firstname.''; -if ($action != 'edit') -{ - // Barre d'actions - if ($user->societe_id == 0) - { - print '
'; - - if ($user->rights->societe->contact->creer) + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - print ''.$langs->trans('Modify').''; + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + + print ''.$langs->trans("Company").''.$objsoc->getNomUrl(1).''; + } + + else + { + print ''.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } } - print "
"; + // Civility + print ''.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print ''; + + // Date To Birth + print ''; + if (! empty($object->birthday)) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + print ''.$langs->trans("DateToBirth").''.dol_print_date($object->birthday,"day"); + + print '   '; + //var_dump($birthdatearray); + $ageyear=convertSecondToTime($now-$object->birthday,'year')-1970; + $agemonth=convertSecondToTime($now-$object->birthday,'month')-1; + if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; + else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; + else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; + + + print '   -   '; + if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); + else print $langs->trans("BirthdayAlertOff"); + print ''; + } + else + { + print ''.$langs->trans("DateToBirth").''.$langs->trans("Unknown").""; + } + print ""; + + print ""; + + } + + dol_fiche_end(); + + if ($action != 'edit') + { + // Barre d'actions + if ($user->societe_id == 0) + { + print '
'; + + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans('Modify').''; + } + + print "
"; + } } } @@ -249,4 +252,3 @@ if ($action != 'edit') llxFooter(); $db->close(); -?> diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index 76d73133e0f..6e439b7a575 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -35,70 +35,72 @@ $id = GETPOST('id', 'int'); $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $contact = new Contact($db); -$result=$contact->fetch($id); -$physicalperson=1; - -$company = new Societe($db); -if ($contact->socid) +if ($id > 0) { - $result=$company->fetch($contact->socid); - //print "ee"; + $result=$contact->fetch($id); + + $physicalperson=1; + + $company = new Societe($db); + if ($contact->socid) + { + $result=$company->fetch($contact->socid); + //print "ee"; + } + + // We create VCard + $v = new vCard(); + $v->setProdId('Dolibarr '.DOL_VERSION); + + $v->setUid('DOLIBARR-CONTACTID-'.$contact->id); + $v->setName($contact->lastname, $contact->firstname, "", "", ""); + $v->setFormattedName($contact->getFullName($langs)); + + // By default, all informations are for work (except phone_perso and phone_mobile) + $v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE"); + $v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE"); + $v->setPhoneNumber($contact->fax, "WORK;FAX"); + + $v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK;POSTAL"); + $v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK"); + $v->setEmail($contact->email,'internet,pref'); + $v->setNote($contact->note); + + $v->setTitle($contact->poste); + + // Data from linked company + if ($company->id) + { + $v->setURL($company->url, "WORK"); + if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "WORK;VOICE"); + if (! $contact->fax) $v->setPhoneNumber($company->fax, "WORK;FAX"); + if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, "", $company->zip, $company->country_code, "WORK;POSTAL"); + if ($company->email != $contact->email) $v->setEmail($company->email,'internet'); + // Si contact lie a un tiers non de type "particulier" + if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->nom); + } + + // Personal informations + $v->setPhoneNumber($contact->phone_perso, "HOME;VOICE"); + if ($contact->birthday) $v->setBirthday($contact->birthday); + + $db->close(); + + + // Renvoi la VCard au navigateur + + $output = $v->getVCard(); + + $filename =trim(urldecode($v->getFileName())); // "Nom prenom.vcf" + $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); + //$filename = dol_sanitizeFileName($filename); + + + header("Content-Disposition: attachment; filename=\"".$filename."\""); + header("Content-Length: ".dol_strlen($output)); + header("Connection: close"); + header("Content-Type: text/x-vcard; name=\"".$filename."\""); + + print $output; } - -// We create VCard -$v = new vCard(); -$v->setProdId('Dolibarr '.DOL_VERSION); - -$v->setUid('DOLIBARR-CONTACTID-'.$contact->id); -$v->setName($contact->lastname, $contact->firstname, "", "", ""); -$v->setFormattedName($contact->getFullName($langs)); - -// By default, all informations are for work (except phone_perso and phone_mobile) -$v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE"); -$v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE"); -$v->setPhoneNumber($contact->fax, "WORK;FAX"); - -$v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK;POSTAL"); -$v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, ($contact->country_code?$contact->country_id:''), "WORK"); -$v->setEmail($contact->email,'internet,pref'); -$v->setNote($contact->note); - -$v->setTitle($contact->poste); - -// Data from linked company -if ($company->id) -{ - $v->setURL($company->url, "WORK"); - if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "WORK;VOICE"); - if (! $contact->fax) $v->setPhoneNumber($company->fax, "WORK;FAX"); - if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, "", $company->zip, $company->country_code, "WORK;POSTAL"); - if ($company->email != $contact->email) $v->setEmail($company->email,'internet'); - // Si contact lie a un tiers non de type "particulier" - if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->nom); -} - -// Personal informations -$v->setPhoneNumber($contact->phone_perso, "HOME;VOICE"); -if ($contact->birthday) $v->setBirthday($contact->birthday); - -$db->close(); - - -// Renvoi la VCard au navigateur - -$output = $v->getVCard(); - -$filename =trim(urldecode($v->getFileName())); // "Nom prenom.vcf" -$filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); -//$filename = dol_sanitizeFileName($filename); - - -header("Content-Disposition: attachment; filename=\"".$filename."\""); -header("Content-Length: ".dol_strlen($output)); -header("Connection: close"); -header("Content-Type: text/x-vcard; name=\"".$filename."\""); - -print $output; - -?>