diff --git a/ChangeLog b/ChangeLog index d8d87f2a6c8..d3274e1048d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,7 +11,6 @@ during migration. Upgrading to any other version or any other database system is abolutely required BEFORE trying make a Dolibarr upgrade. - ***** ChangeLog for 3.9.3 compared to 3.9.2 ***** FIX: #4383 $userid not defined FIX: #4448 $filebonprev is not used, $this->filename now @@ -311,7 +310,68 @@ This is list of hooks modified: - Remove deprecated Product::hidden property - + +***** ChangeLog for 3.8.5 compared to 3.8.4 ***** +FIX: #3815 Call to undefined function local_by_date(). +FIX: #4424 Missing email of user popup in supplier orders area +FIX: #4442 Missing translation in Banks menu +FIX: #4448 $filebonprev is not used, $this->filename now +FIX: #4455 +FIX: #4737 Bank transacion type selector translation is cropped +FIX: #4742 Able to delete a supplier invoice with a registered payment +FIX: #4743 UI glitch in project summary page +FIX: #4747 Missing UI background when registering a supplier invoice payment +FIX: #4748 Supplier invoice payment confirmation amount is not translated +FIX: #4749 +FIX: #4756 +FIX: #4766 VAT not shown in supplier invoice popup +FIX: #4809 - Duplicate functions with different content +FIX: #4851 Project selector in supplier invoices shows the project label twice +FIX: #4870 +FIX: #5008 SQL error when editing the reference of a supplier invoice that already exists +FIX: #5048 Product supplier list display only one produc +FIX: #5170 tva sign with INVOICE_POSITIVE_CREDIT_NOTE option +FIX: #5203 +FIX: #5207 +FIX: #5338 use of not initialized var $aphour, $apmin, etc +FIX: #5380 +FIX: #5383 bad object id on don delete +FIX: #5474 Country_id of "Don" object is still empty +FIX: Accountancy - 3.8 - Chart of accounts are limited on only one country +FIX: Bad include and param for project numbering module call +FIX: Box disabled because bugged +FIX: bug on email template +FIX: Can correct stock of lot using eatby or sell by date +FIX: Can make a movement on "out of sell" products +FIX: Can't create thirdparty or validate invoice if profid is mandatory and profid does not exists for other countries +FIX: can't fetch by siret or siren because of first "if" +FIX: Check stock of product by warehouse if $entrepot_id defined on shippings +FIX: correct display of minimum buying price +FIX: Creation of thumb image for size "small" was not done. +FIX: Direction of movement lost if an error occurs +FIX: dont retrieve new buying price on margin display +FIX: Duplicate records into export +FIX: Email templates not compatible with Multicompany +FIX: end of select when no fournprice +FIX: finished parameters not used +FIX: hook on group card called but not initialized +FIX: It doesn't check if there is enough stock to update the lines of orders/invoices +FIX: large expense note +FIX: missing column when module was installed before standard integration +FIX: Missing database escaping on supplier price insert/update +FIX: Not filtering correctly when come from dashboard +FIX: PROPAL_MERGE_PDF with PRODUCT_USE_OLD_PATH +FIX: real min buying price +FIX: receiving link never works +FIX: same page added several times on mergepropal option +FIX: search on date into supplier invoice list dont work because of status -1 +FIX: Search supplier ref on contract +FIX: SQL error function on getAvailableDiscounts function, on bill create mode if socid is empty +FIX: systematic rounding causes prices to be updated without reason +FIX: task ODT company object not correctly retrieved +FIX: Template email must take care of positino column +FIX: VAT rate can be negative. Example spain selling to morroco. + ***** ChangeLog for 3.8.4 compared to 3.8.3 ***** FIX: #3694 FIX: #3798 #2519 Cron jobs would never be executed diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 5e9fc895f0b..bef8c6951bf 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2011-2015 Philippe Grand * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García @@ -624,7 +624,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i=0; foreach ($listfieldinsert as $f => $value) { - if ($value == 'price' || preg_match('/^amount/i',$value) || preg_match('/^localtax/i',$value) || $value == 'taux') { + if ($value == 'price' || preg_match('/^amount/i',$value) || $value == 'taux') { $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); } else if ($value == 'entity') { @@ -672,7 +672,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i = 0; foreach ($listfieldmodify as $field) { - if ($field == 'price' || preg_match('/^amount/i',$field) || preg_match('/^localtax/i',$field) || $field == 'taux') { + if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') { $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU'); } else if ($field == 'entity') { @@ -1290,23 +1290,12 @@ if ($id) $valuetoshow = ''; $align="center"; } - else if ($fieldlist[$field]=='localtax1') { + else if ($fieldlist[$field]=='taux') { $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); if ($obj->localtax1 == 0) $valuetoshow = ''; $align="right"; } - else if ($fieldlist[$field]=='localtax2') { - $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - if ($obj->localtax2 == 0) - $valuetoshow = ''; - $align="right"; - } - else if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) - { - $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - $align="right"; - } else if (in_array($fieldlist[$field],array('recuperableonly'))) { $align="center"; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 51d0a6174c8..3147538c8fe 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -167,7 +167,7 @@ if ($action == 'edit') // Edit print ' '; print ''; - // Multilangual GUI + // Multilingual GUI $var=!$var; print ''.$langs->trans("EnableMultilangInterface").''; print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1); @@ -181,7 +181,7 @@ if ($action == 'edit') // Edit show_theme(null,1); print '
'; - // Liste des zone de recherche permanantes supportees + // List of permanent supported search box if (! empty($searchform)) { print ''; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 05c13d1abe3..7e01098a5f8 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2013-2016 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud @@ -602,17 +602,19 @@ class Categorie extends CommonObject { if ($this->db->num_rows($resql) > 0) { - $objparent = $this->db->fetch_object($resql); + $objparent = $this->db->fetch_object($resql); if (!empty($objparent->fk_parent)) { $cat = new Categorie($this->db); - $cat->id=$objparent->fk_parent; - $result=$cat->add_type($obj, $type); - if ($result < 0) - { - $this->error=$cat->error; - $error++; + $cat->id = $objparent->fk_parent; + if (!$cat->containsObject($type, $obj->id)) { + $result = $cat->add_type($obj, $type); + if ($result < 0) + { + $this->error = $cat->error; + $error++; + } } } } diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index eef29d2edc3..4d6c0e289f5 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -69,7 +69,7 @@ if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db); if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db); if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db); -llxHeader(); +llxHeader("",$langs->trans("CommercialArea")); print load_fiche_titre($langs->trans("CommercialArea"),'','title_commercial.png'); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 463c81266f8..25ed1acb27e 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2734,20 +2734,33 @@ class Propal extends CommonObject */ function getNomUrl($withpicto=0,$option='', $get_params='') { - global $langs, $conf; + global $langs, $conf, $user; $result=''; - $label = '' . $langs->trans("ShowPropal") . ''; - if (! empty($this->ref)) - $label.= '
'.$langs->trans('Ref').': '.$this->ref; - if (! empty($this->ref_client)) - $label.= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; - if (! empty($this->total_ht)) - $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_tva)) - $label.= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_ttc)) - $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + $label = ''; + + if ($user->rights->propal->lire) { + $label .= ''.$langs->trans("ShowPropal").''; + if (!empty($this->ref)) { + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->ref_client)) { + $label .= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; + } + if (!empty($this->total_ht)) { + $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, + $conf->currency); + } + if (!empty($this->total_tva)) { + $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, + $conf->currency); + } + if (!empty($this->total_ttc)) { + $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, + $conf->currency); + } + } + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; if ($option == '') { $link = ''; - if (! empty($this->ref)) - $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->ref_client)) - $label.= '
' . $langs->trans('RefCustomer') . ': ' . $this->ref_client; - if (! empty($this->total_ht)) - $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_tva)) - $label.= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - if (! empty($this->total_ttc)) - $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + $label = ''; + + if ($user->rights->commande->lire) { + $label = ''.$langs->trans("ShowOrder").''; + if (!empty($this->ref)) { + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->ref_client)) { + $label .= '
'.$langs->trans('RefCustomer').': '.$this->ref_client; + } + if (!empty($this->total_ht)) { + $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, + $conf->currency); + } + if (!empty($this->total_tva)) { + $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, + $conf->currency); + } + if (!empty($this->total_ttc)) { + $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, + $conf->currency); + } + } $linkstart = '
'; $linkend=''; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index cfb8486be6f..f9653c06732 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -259,6 +259,7 @@ if ($resql) $title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); $param=''; + if ($sall) $param.='&sall='.$sall; if ($socid > 0) $param.='&socid='.$socid; if ($viewstatut != '') $param.='&viewstatut='.$viewstatut; if ($orderday) $param.='&orderday='.$orderday; @@ -587,10 +588,13 @@ if ($resql) print dol_print_date($db->jdate($objp->date_commande), 'day'); print ''; - // Delivery date - print '
'; + if (empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)) + { + // Delivery date + print ''; + } // Amount HT print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 659bcaae7c4..34ed1383e14 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -66,7 +66,6 @@ if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); if (! empty($conf->margin->enabled)) $langs->load('margins'); -$sall = trim(GETPOST('sall')); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fd0a61b638f..b2b95d74963 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -530,7 +530,7 @@ if ($search_user > 0) } if (! $sall) { - $sql.= ' GROUP BY f.rowid, f.facnumber, ref_client, f.type, f.note_private, f.note_public, f.increment, f.total, f.tva, f.total_ttc,'; + $sql.= ' GROUP BY f.rowid, f.facnumber, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.total, f.tva, f.total_ttc,'; $sql.= ' f.datef, f.date_lim_reglement,'; $sql.= ' f.paye, f.fk_statut,'; $sql.= ' s.nom, s.rowid, s.code_client, s.client'; @@ -568,6 +568,7 @@ if ($resql) } $param='&socid='.$socid; + if ($sall) $param.='&sall='.$sall; if ($day) $param.='&day='.$day; if ($month) $param.='&month='.$month; if ($year) $param.='&year=' .$year; diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 98ebe63f3b7..f0ef12a2e9c 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -273,7 +273,8 @@ $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'"; $sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'"; $sql.= " AND localtaxtype=".$localTaxType; -$sql.= " GROUP BY dm ASC"; +$sql.= " GROUP BY dm"; +$sql.= " ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 131efda6e34..f007fa41d21 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur - * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014-2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -919,7 +919,7 @@ class BonPrelevement extends CommonObject $dir=$conf->prelevement->dir_output.'/receipts'; if (! is_dir($dir)) dol_mkdir($dir); - $this->filename = $dir.'/receipts/'.$ref.'.xml'; + $this->filename = $dir.'/'.$ref.'.xml'; // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; @@ -1558,7 +1558,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR =''; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.('AS-'.$row_facnumber.'-'.$Rowing).''.$CrLf; + $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.round($row_somme, 2).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; @@ -1673,8 +1673,9 @@ class BonPrelevement extends CommonObject * @return string String with SEPA Sender */ function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n') - { // SEPA INITIALISATION - global $confs; + { + // SEPA INITIALISATION + global $conf; $dateTime_YMD = dol_print_date($ladate, '%Y%m%d'); $dateTime_ETAD = dol_print_date($ladate, '%Y-%m-%d'); diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index c2316578130..25ae7c52c50 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -141,7 +141,7 @@ if ($prev_id) print price($row[0]); print ''; print "\n"; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d9fa371e443..8d9c3f0ae64 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -364,6 +364,7 @@ if ($result) $param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); $param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_lastname='.urlencode($search_lastname).'&search_firstname='.urlencode($search_firstname).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email); if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ); + if ($sall != '') $param.='&sall='.urlencode($sall); if ($search_lastname != '') $param.='&search_lastname='.urlencode($search_lastname); if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_firstname); if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 23df8a06593..4f808e73be3 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -222,6 +223,7 @@ if ($resql) $param.='&search_name='.$search_name; $param.='&search_ref_supplier='.$search_ref_supplier; $param.='&search_sale=' .$search_sale; + if ($sall != '') $param.='&sall='.$sall; if ($optioncss != '') $param.='&optioncss='.$optioncss; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'',$sortfield,$sortorder); diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 58c48d5b254..d56dc28cadf 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -80,11 +80,11 @@ if(! empty($_POST['removAll'])) { $pathtodelete = $value; $filetodelete = $listofnames[$key]; - $result = dol_delete_file($pathtodelete,1); // Delete uploded Files - + $result = dol_delete_file($pathtodelete,1); // Delete uploded Files + $langs->load("other"); setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs'); - + $formmail->remove_attached_files($key); // Update Session } } @@ -117,29 +117,29 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $dolimail = new Dolimail($db); $possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1"); $possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople - if (!$possibleaccounts && !$possibleuser) + if (!$possibleaccounts && !$possibleuser) { setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors'); } - elseif (count($possibleaccounts)>1) + elseif (count($possibleaccounts)>1) { $sendtosocid=$possibleaccounts[1]['id']; $result=$object->fetch($sendtosocid); - + setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); } - else + else { - if($possibleaccounts){ + if($possibleaccounts){ $sendtosocid=$possibleaccounts[1]['id']; $result=$object->fetch($sendtosocid); - }elseif($possibleuser){ + }elseif($possibleuser){ $sendtosocid=$possibleuser[0]['id']; $result=$uobject->fetch($sendtosocid); $object=$uobject; } - + } } } @@ -236,35 +236,35 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $mailboxconfig = new IMAP($db); $mailboxconfig->fetch($mbid); if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref(); - + $mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox; $mailboxconfig->userfolder_fetch(); - + if ($mailboxconfig->mailbox_save_sent_mails == 1) { - + $folder=str_replace($ref, '', $mailboxconfig->folder_cache_key); if (!$folder) $folder = "Sent"; // Default Sent folder - + $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password); - if (FALSE === $mailboxconfig->mbox) + if (FALSE === $mailboxconfig->mbox) { $info = FALSE; $err = $langs->trans('Error3_Imap_Connection_Error'); setEventMessages($err,$mailboxconfig->element, null, 'errors'); - } - else + } + else { $mailboxconfig->mailboxid=$_POST['frommail']; $mailboxconfig->foldername=$folder; $from = $mailfromid[0] . $mailfromid[2]; $imap=1; } - - } + + } } } - + // Send mail require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid); @@ -278,7 +278,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($result) { $error=0; - + // FIXME This must be moved into a trigger for action $trigger_name if (! empty($conf->dolimail->enabled)) { @@ -289,13 +289,13 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $dolimail=new DoliMail($db); $dolimail->id = $mid; $res=$dolimail->set_prop($user, 'answered',1); - } + } if ($imap==1) { // write mail to IMAP Server - $movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile); + $movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile); if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs'); - else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); + else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); } } @@ -313,7 +313,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $interface=new Interfaces($db); $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); if ($result < 0) { - $error++; $this->errors=$interface->errors; + $error++; $errors=$interface->errors; } // End call of triggers @@ -327,8 +327,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val); - else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id); + if ($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val); + else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id); exit; } } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 7d819ec0d2b..1db7b5729db 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -2,6 +2,7 @@ /* Copyright (C) 2012-2014 Charles-François BENKE * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Juan José Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -79,8 +80,10 @@ class box_project extends ModeleBoxes $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut "; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + if($user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=p.fk_soc"; $sql.= " WHERE p.entity = ".$conf->entity; - $sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; + $sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts $sql.= " ORDER BY p.datec DESC"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 5804ab4cf9f..9b233ef6b74 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -35,8 +35,8 @@ abstract class CommonDocGenerator { var $error=''; protected $db; - - + + /** * Constructor * @@ -59,6 +59,8 @@ abstract class CommonDocGenerator { global $conf; + $logotouse=$conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; + return array( 'myuser_lastname'=>$user->lastname, 'myuser_firstname'=>$user->firstname, @@ -75,7 +77,7 @@ abstract class CommonDocGenerator 'myuser_fax'=>$user->office_fax, 'myuser_mobile'=>$user->user_mobile, 'myuser_email'=>$user->email, - 'myuser_logo'=>$user->photo, + 'myuser_logo'=>$logotouse, 'myuser_job'=>$user->job, 'myuser_web'=>'' // url not exist in $user object ); @@ -390,7 +392,7 @@ abstract class CommonDocGenerator // Add vat by rates foreach ($object->lines as $line) { - // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility + // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); @@ -430,7 +432,7 @@ abstract class CommonDocGenerator 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), 'line_product_ref'=>$line->product_ref, 'line_product_label'=>$line->product_label, - 'line_product_type'=>$line->product_type, + 'line_product_type'=>$line->product_type, 'line_desc'=>$line->desc, 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), 'line_up'=>price2num($line->subprice), @@ -444,9 +446,9 @@ abstract class CommonDocGenerator 'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs), 'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs), 'line_date_start'=>$line->date_start, - 'line_date_start_rfc'=>dol_print_date($line->date_start,'rfc'), + 'line_date_start_rfc'=>dol_print_date($line->date_start,'dayrfc'), 'line_date_end'=>$line->date_end, - 'line_date_end_rfc'=>dol_print_date($line->date_end,'rfc') + 'line_date_end_rfc'=>dol_print_date($line->date_end,'dayrfc') ); // Retrieve extrafields @@ -582,7 +584,7 @@ abstract class CommonDocGenerator $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; } else if($extrafields->attribute_type[$key] == 'date') - { + { if (strlen($object->array_options['options_'.$key])>0) { $object->array_options['options_'.$key] = dol_print_date($object->array_options['options_'.$key],'day'); // using company output language diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c3140118745..3279d372a0e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -448,7 +448,7 @@ abstract class CommonObject global $conf, $langs; $countriesusingstate=array('AU','US','IN','GB','ES','UK','TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS - + $contactid=0; $thirdpartyid=0; if ($this->element == 'societe') @@ -465,12 +465,12 @@ abstract class CommonObject $contactid=$this->contact_id; $thirdpartyid=$object->fk_soc; } - + $out=''; - + $outdone=0; $coords = $this->getFullAddress(1,', '); - if ($coords) + if ($coords) { if (! empty($conf->use_javascript_ajax)) { @@ -485,7 +485,7 @@ abstract class CommonObject } if (! in_array($this->country_code,$countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress - && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) + && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) { $out.=($outdone?' - ':'').$this->state; $outdone++; @@ -516,15 +516,15 @@ abstract class CommonObject if (! empty($this->office_fax)) { $out.=dol_print_phone($this->fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX',' ','fax',$langs->trans("Fax")); $outdone++; } - + $out.='
'; $outdone=0; - if (! empty($this->email)) + if (! empty($this->email)) { $out.=dol_print_email($this->email,$this->id,$object->id,'AC_EMAIL',0,0,1); $outdone++; } - if (! empty($this->url)) + if (! empty($this->url)) { $out.=dol_print_url($this->url,'',0,1); $outdone++; @@ -535,12 +535,12 @@ abstract class CommonObject if ($this->skype) $out.=dol_print_skype($this->skype,$this->id,$object->id,'AC_SKYPE'); $outdone++; } - + $out.=''; - + return $out; } - + /** * Add a link between element $this->element and a contact * @@ -595,50 +595,56 @@ abstract class CommonObject } } - $datecreate = dol_now(); - - $this->db->begin(); - // Insertion dans la base - $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; - $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; - $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; - $sql.= "'".$this->db->idate($datecreate)."'"; - $sql.= ", 4, '". $id_type_contact . "' "; - $sql.= ")"; - dol_syslog(get_class($this)."::add_contact", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if (! $notrigger) - { - $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); - if ($result < 0) - { - $this->db->rollback(); + if(! empty($id_type_contact)) { + + $datecreate = dol_now(); + + $this->db->begin(); + + // Insertion dans la base + $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; + $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; + $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; + $sql.= "'".$this->db->idate($datecreate)."'"; + $sql.= ", 4, ". $id_type_contact . " "; + $sql.= ")"; + dol_syslog(get_class($this)."::add_contact", LOG_DEBUG); + + $resql=$this->db->query($sql); + if ($resql) + { + if (! $notrigger) + { + $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + } + + $this->db->commit(); + return 1; + } + else + { + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $this->error=$this->db->errno(); + $this->db->rollback(); + return -2; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); return -1; } - } - - $this->db->commit(); - return 1; - } - else - { - if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $this->error=$this->db->errno(); - $this->db->rollback(); - return -2; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } + } } + return 1; } /** @@ -1196,7 +1202,7 @@ abstract class CommonObject if (!empty($id) && !empty($field) && !empty($table)) { $sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE rowid = ".$id; - + dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -2275,8 +2281,8 @@ abstract class CommonObject * - all parameters empty -> we look all link to current object (current object can be source or target) * - one couple id+type is provided -> this will set $justsource or $justtarget * - one couple id+type is provided and other type is provided -> this will set $justsource or $justtarget + criteria on other type - * - * + * + * * @param int $sourceid Object source id (if not defined, id of object) * @param string $sourcetype Object source type (if not defined, element name of object) * @param int $targetid Object target id (if not defined, id of object) @@ -3223,7 +3229,7 @@ abstract class CommonObject $text.= ' - '.(! empty($line->label)?$line->label:$label); $description.=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc. } - + $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) @@ -3662,7 +3668,7 @@ abstract class CommonObject return -1; } } - + // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; @@ -3726,13 +3732,13 @@ abstract class CommonObject /* For default values */ /** - * Return the default value to use for a field when showing the create form of object. + * Return the default value to use for a field when showing the create form of object. * Return values in this order: * 1) If parameter is available into POST, we return it first. * 2) If not but an alternate value was provided as parameter of function, we return it. - * 3) If not but a constant $conf->global->OBJECTELEMENT_FIELDNAME is set, we return it (It is better to use the dedicated table). + * 3) If not but a constant $conf->global->OBJECTELEMENT_FIELDNAME is set, we return it (It is better to use the dedicated table). * 4) Return value found into database (TODO No yet implemented) - * + * * @param string $fieldname Name of field * @param string $alternatevalue Alternate value to use * @return string Default value @@ -3743,27 +3749,27 @@ abstract class CommonObject // If param is has been posted with use this value first. if (isset($_POST[$fieldname])) return GETPOST($fieldname, 2); - + if (isset($alternatevalue)) return $alternatevalue; - + $newelement=$this->element; if ($newelement == 'facture') $newelement='invoice'; if ($newelement == 'commande') $newelement='order'; - if (empty($newelement)) + if (empty($newelement)) { dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING); return ''; } - + $keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname); //var_dump($keyforfieldname); if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname; - - // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname - + + // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname + } - - + + /* For triggers */ @@ -3963,7 +3969,7 @@ abstract class CommonObject { $res=$object->fetch(0,$value); if ($res > 0) $this->array_options[$key]=$object->id; - else + else { $this->error="Ref '".$value."' for object '".$object->element."' not found"; $this->db->rollback(); @@ -4196,25 +4202,25 @@ abstract class CommonObject return true; } - + /** * define buy price if not defined * set buy price = sell price if ForceBuyingPriceIfNull configured, * else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, set pmp as buyprice * else set min buy price as buy price - * + * * @param float $unitPrice product unit price * @param float $discountPercent line discount percent * @param int $fk_product product id * * @return float <0 if ko, buyprice if ok */ - public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0) + public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0) { global $conf; - + $buyPrice = 0; - + if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { $buyPrice = $unitPrice * (1 - $discountPercent / 100); diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 35c3b3909ef..7e68589c5f9 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -108,7 +108,7 @@ class DolEditor // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? $modulepart='fckeditor'; - $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&file='; + $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/' ; $this->editor->Config['LinkBrowser']=($uselocalbrowser?'true':'false'); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index d63c2536476..52c3b2f5cb9 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -675,7 +675,7 @@ class ExtraFields if ($showsize > 48) $showsize=48; } } - + if (in_array($type,array('date','datetime'))) { $tmp=explode(',',$size); @@ -812,7 +812,7 @@ class ExtraFields if (strpos($InfoFieldList[4], '$SEL$')!==false) { $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); } - + // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); @@ -830,14 +830,14 @@ class ExtraFields $sqlwhere.= ' WHERE '.$InfoFieldList[4]; } } - else + else { $sqlwhere.= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. - if (in_array($InfoFieldList[0],array('tablewithentity'))) + if (in_array($InfoFieldList[0],array('tablewithentity'))) { - $sqlwhere.= ' AND entity = '.$conf->entity; + $sqlwhere.= ' AND entity = '.$conf->entity; } $sql.=$sqlwhere; //print $sql; @@ -996,19 +996,19 @@ class ExtraFields $sql = 'SELECT ' . $keyList; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; if (! empty($InfoFieldList[4])) { - + // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$')!==false) { $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); } - + // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) { $InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]); } else { $InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]); } - + // We have to join on extrafield table if (strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra'; @@ -1020,13 +1020,13 @@ class ExtraFields $sqlwhere .= ' WHERE 1=1'; } // Some tables may have field, some other not. For the moment we disable it. - if (in_array($InfoFieldList[0], array ('tablewithentity'))) + if (in_array($InfoFieldList[0], array ('tablewithentity'))) { $sqlwhere .= ' AND entity = ' . $conf->entity; } // $sql.=preg_replace('/^ AND /','',$sqlwhere); // print $sql; - + $sql .= $sqlwhere; dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG); $resql = $this->db->query($sql); @@ -1232,7 +1232,14 @@ class ExtraFields { $sql.= ' as main'; } - $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; + if ($selectkey=='rowid' && empty($value)) { + $sql.= " WHERE ".$selectkey."=0"; + } elseif ($selectkey=='rowid') { + $sql.= " WHERE ".$selectkey."=".$this->db->escape($value); + }else { + $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; + } + //$sql.= ' AND entity = '.$conf->entity; dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG); @@ -1391,10 +1398,10 @@ class ExtraFields $showsize=round($size); if ($showsize > 48) $showsize=48; } - + //print $type.'-'.$size; $out=$value; - + return $out; } @@ -1411,7 +1418,7 @@ class ExtraFields $type=$this->attribute_type[$key]; $align=''; - + if ($type == 'date') { $align="center"; @@ -1440,10 +1447,10 @@ class ExtraFields { $align="center"; } - + return $align; } - + /** * Return HTML string to print separator extrafield * @@ -1523,7 +1530,7 @@ class ExtraFields return 0; } } - + /** * return array_options array for object by extrafields value (using for data send by forms) * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 048ef2d450d..304006402c2 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1093,7 +1093,7 @@ class DoliDBPgsql extends DoliDB */ function DDLDropField($table,$field_name) { - $sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; + $sql= "ALTER TABLE ".$table." DROP COLUMN ".$field_name; dol_syslog($sql,LOG_DEBUG); if (! $this->query($sql)) { diff --git a/htdocs/core/filemanagerdol/connectors/php/config.php b/htdocs/core/filemanagerdol/connectors/php/config.php index 0c3b0a4884c..e21e69bdec2 100644 --- a/htdocs/core/filemanagerdol/connectors/php/config.php +++ b/htdocs/core/filemanagerdol/connectors/php/config.php @@ -44,7 +44,8 @@ $Config['Enabled'] = true ; // Path to user files relative to the document root. -$Config['UserFilesPath'] = DOL_URL_ROOT.'/viewimage.php?modulepart=fckeditor&file=' ; +$extEntity=(empty($entity) ? 1 : $entity); // For multicompany with external access +$Config['UserFilesPath'] = DOL_URL_ROOT.'/viewimage.php?modulepart=fckeditor&entity='.$extEntity.'&file=' ; // Fill the following value it you prefer to specify the absolute path for the // user files directory. Useful if you are using a virtual directory, symbolic diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 4d02acc9925..0baea91412f 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1012,6 +1012,9 @@ function getParameterByName(name, valueifnotfound) } })(); +// Another solution, easier, to build a javascript rounding function +function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); } + /** * Function similar to PHP price2num() @@ -1024,7 +1027,7 @@ function price2numjs(amount) { if (amount == '') return ''; transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { $dec = $langs->transnoentitiesnoconv("SeparatorDecimal"); @@ -1032,6 +1035,7 @@ function price2numjs(amount) { if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { $thousand = $langs->transnoentitiesnoconv("SeparatorThousand"); } + if ($thousand == 'Space') $thousand=' '; print "var dec='" . dol_escape_js($dec) . "'; var thousand='" . dol_escape_js($thousand) . "';\n"; // Set var in javascript ?> @@ -1050,11 +1054,15 @@ function price2numjs(amount) { if (nbdec > rounding) rounding = nbdec; // If rounding higher than max shown if (rounding > main_max_dec_shown) rounding = main_max_dec_shown; - if (thousand != ',' && thousand != '.') amount = amount.replace(',', '.'); amount = amount.replace(' ', ''); // To avoid spaces amount = amount.replace(thousand, ''); // Replace of thousand before replace of dec to avoid pb if thousand is . amount = amount.replace(dec, '.'); - - return Math.round10(amount, rounding); + //console.log("amount before="+amount+" rouding="+rounding) + var res = Math.round10(amount, - rounding); + // Other solution is + // var res = dolroundjs(amount, rounding) + console.log("res="+res) + return res; } + diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1f2a9d1d8d9..aaff894fcf9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7,7 +7,7 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2014 Cédric GROSS @@ -3336,7 +3336,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller $vatratecleaned = $vatrate; if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" { - $vatratecleaned = $reg[1]; + $vatratecleaned = trim($reg[1]); $vatratecode = $reg[2]; } @@ -3350,7 +3350,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller { if ($local == 1) { - if (! $mysoc->localtax1_assuj) return 0; + if (! $mysoc->localtax1_assuj || (string) $vatratecleaned == "0") return 0; if ($thirdparty_seller->id == $mysoc->id) { if (! $thirdparty_buyer->localtax1_assuj) return 0; @@ -3363,7 +3363,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller if ($local == 2) { - if (! $mysoc->localtax2_assuj) return 0; + if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; if ($thirdparty_seller->id == $mysoc->id) { if (! $thirdparty_buyer->localtax2_assuj) return 0; @@ -5195,7 +5195,7 @@ function printCommonFooter($zone='private') print 'window.console && console.log("'; if (! empty($conf->global->MEMCACHED_SERVER)) print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - '; print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED)?$conf->global->MAIN_OPTIMIZE_SPEED:'off'); - if ($micro_start_time) + if (! empty($micro_start_time)) // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable. { $micro_end_time = microtime(true); print ' - Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms'; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index deab2457c8b..82449ac63cb 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1493,7 +1493,8 @@ function getListOfModels($db,$type,$maxfilenamelength=0) /** * This function evaluates a string that should be a valid IPv4 - * + * Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patchs of PHP (5.6.25). See https://github.com/php/php-src/pull/1954. + * * @param string $ip IP Address * @return int 0 if not valid or reserved range, 1 if valid and public IP, 2 if valid and private range IP */ diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index aeb7ea4cd8f..12f4fb96545 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -278,7 +278,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest); - + $newcodefortest=$codefortest; // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test @@ -290,7 +290,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); } } - + $result=check_value($mask,$newcodefortest); return $result; diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index d03302f36b7..43924165901 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -87,11 +87,11 @@ abstract class ModeleNumRefBarCode /** * Return next value available * - * @param Societe $objsoc Object thirdparty + * @param Societe $objproduct Object Product * @param int $type Type * @return string Value */ - function getNextValue($objsoc=0,$type=-1) + function getNextValue($objproduct,$type='') { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 974bbac1a3e..ea9ece5229c 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -100,7 +100,8 @@ class pdf_merou extends ModelePdfExpedition $outputlangs->load("propal"); $outputlangs->load("deliveries"); $outputlangs->load("sendings"); - + $outputlangs->load("productbatch"); + if ($conf->expedition->dir_output) { $object->fetch_thirdparty(); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 6cc965c5c4f..db1be5f46e1 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -110,7 +110,8 @@ class pdf_rouget extends ModelePdfExpedition $outputlangs->load("propal"); $outputlangs->load("deliveries"); $outputlangs->load("sendings"); - + $outputlangs->load("productbatch"); + $nblignes = count($object->lines); // Loop on each lines to detect if there is at least one image to show diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index a2fa413b9e8..ff8a73c527d 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -167,7 +167,7 @@ class pdf_crabe extends ModelePDFFactures function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { global $user,$langs,$conf,$mysoc,$db,$hookmanager; - + if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; @@ -252,7 +252,7 @@ class pdf_crabe extends ModelePDFFactures // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); - + // Create pdf instance $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance @@ -337,6 +337,11 @@ class pdf_crabe extends ModelePDFFactures $height_incoterms = 0; if ($conf->incoterm->enabled) { + if (is_object($object->thirdparty)) + { + $object->fk_incoterms=$object->thirdparty->fk_incoterms; + $object->location_incoterms=$object->thirdparty->location_incoterms; + } $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { @@ -550,7 +555,7 @@ class pdf_crabe extends ModelePDFFactures } else { $tvaligne = $sign * $object->lines[$i]->total_tva; } - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; @@ -1557,7 +1562,7 @@ class pdf_crabe extends ModelePDFFactures $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - + $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index da59679b1be..2db005c5646 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -504,6 +504,10 @@ class ImportCsv extends ModeleImports } if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" } + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') + { + $newval = price2num($newval); + } //print 'Val to use as insert is '.$newval.'
'; } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index ad4c2bba16a..02546e6af11 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2014 Laurent Destailleur - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -302,6 +302,7 @@ class modCategorie extends DolibarrModules $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p'; $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc'; + $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = p.rowid'; $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category',1).')'; $this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index 5557104c7f6..7eefc6ebd94 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -69,7 +69,7 @@ class modProductBatch extends DolibarrModules $this->config_page_url = array(); // Dependencies - $this->depends = array("modProduct","modStock","modExpedition","modSupplier"); // List of modules id that must be enabled if this module is enabled. modExpedition is required to manage batch exit (by manual stock decrease on shipment), modSupplier to manage batch entry (after supplier order). + $this->depends = array("modProduct","modStock","modExpedition","modFournisseur"); // List of modules id that must be enabled if this module is enabled. modExpedition is required to manage batch exit (by manual stock decrease on shipment), modSupplier to manage batch entry (after supplier order). $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 778fd7a9865..5116f94ae24 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -405,7 +405,8 @@ class modSociete extends DolibarrModules 's.code_client'=>array('rule'=>'getcustomercodeifauto'), 's.code_fournisseur'=>array('rule'=>'getsuppliercodeifauto'), 's.code_compta'=>array('rule'=>'getcustomeraccountancycodeifauto'), - 's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifauto') + 's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifauto'), + 's.capital'=>array('rule'=>'numeric') ); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index b881f45dab0..95b0c00ff5b 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -211,7 +211,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $hookmanager->initHooks(array('pdfgeneration')); $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $nblignes = count($object->lines); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 1e9a13069ae..83d596dbd61 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -99,7 +99,7 @@ $coldisplay=-1; // We remove first td $doleditor=new DolEditor('product_desc',$line->description,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%'); $doleditor->Create(); } else { - print ''; + print ''; } ?> diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 39eaacd303f..ed7ece5bc84 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1023,21 +1023,21 @@ class Cronjob extends CommonObject } if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); } - } - dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG); + dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG); - - // Update with result - $this->lastoutput=''; - if (is_array($output_arr) && count($output_arr)>0) - { - foreach($output_arr as $val) + // Update with result + $this->lastoutput=''; + if (is_array($output_arr) && count($output_arr)>0) { - $this->lastoutput.=$val."\n"; + foreach($output_arr as $val) + { + $this->lastoutput.=$val."\n"; + } } + $this->lastresult=$retval; } - $this->lastresult=$retval; + $this->datelastresult=dol_now(); $result = $this->update($user); if ($result < 0) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 8a40c85b191..0dd6d1d8a29 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -712,7 +712,7 @@ if (! empty($id) && $action != 'edit') print ''; } - if (($object->statut == 0 || $object->statut == 1) && $remaintopay == 0 && $object->paye == 0) + if (($object->statut == 0 || $object->statut == 1) && $remaintopay == 0 && $object->paid == 0) { print '"; } diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 36dfb1db55e..34b452985d5 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -124,6 +125,7 @@ if ($resql) $expedition = new Expedition($db); $param=""; + if ($sall) $param.= "&sall=".$sall; if ($search_ref_exp) $param.= "&search_ref_exp=".$search_ref_exp; if ($search_ref_liv) $param.= "&search_ref_liv=".$search_ref_liv; if ($search_company) $param.= "&search_company=".$search_company; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index efa6572dd10..b24f5fcfe01 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -193,6 +193,7 @@ if ($resql) $i = 0; $param=""; + if ($sall) $param.="&sall=".$sall; if ($search_ref) $param.="&search_ref=".$search_ref; if ($search_user) $param.="&search_user=".$search_user; if ($search_amount_ht) $param.="&search_amount_ht=".$search_amount_ht; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 74edaf72099..d01911df6ff 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -139,6 +139,7 @@ if ($result) $num = $db->num_rows($result); $urlparam=''; + if ($sall) $urlparam.="&sall=".$sall; if ($socid) $urlparam.="&socid=".$socid; if ($search_ref) $urlparam.="&search_ref=".urlencode($search_ref); if ($search_company) $urlparam.="&search_company=".urlencode($search_company); diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 57824abe795..14dd1f0e318 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.3'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.4'); if (! defined('EURO')) define('EURO',chr(128)); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 80b02718878..870b52667dc 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -383,7 +383,6 @@ if ($object->id > 0) $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; $sql.= " WHERE p.fk_soc =".$object->id; $sql.= " AND p.entity =".$conf->entity; - $sql.= " ORDER BY p.date_commande DESC"; $resql=$db->query($sql); if ($resql) { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 19395db756c..11d755b50a4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -65,7 +65,7 @@ class CommandeFournisseur extends CommonOrder // -> 9=Refused -> (reopen) 1=Validated // Note: billed or not is on another field "billed" var $statuts; // List of status - + var $socid; var $fourn_id; var $date; @@ -254,6 +254,8 @@ class CommandeFournisseur extends CommonOrder $this->fetchObjectLinked(); + $this->lines=array(); + $sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description,"; $sql.= " l.qty,"; $sql.= " l.tva_tx, l.remise_percent, l.subprice,"; @@ -517,7 +519,7 @@ class CommandeFournisseur extends CommonOrder $billedtext=''; //if ($statut==5 && $this->billed == 1) $statut = 8; if ($billed == 1) $billedtext=$langs->trans("Billed"); - + // List of language codes for status $statutshort[0] = 'StatusOrderDraftShort'; $statutshort[1] = 'StatusOrderValidatedShort'; @@ -991,6 +993,8 @@ class CommandeFournisseur extends CommonOrder $this->date_commande = $this->db->idate($date); $result = 1; $this->log($user, 3, $date, $comment); + $this->date_commande = $date; + $this->methode_commande = $methode; } else { @@ -1356,7 +1360,7 @@ class CommandeFournisseur extends CommonOrder $localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc,$this->thirdparty); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2115,7 +2119,7 @@ class CommandeFournisseur extends CommonOrder $localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc, $this->thirdparty); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2533,10 +2537,10 @@ class CommandeFournisseur extends CommonOrder public function hasDelay() { global $conf; - + $now = dol_now(); $date_to_test = empty($this->date_livraison) ? $this->date_commande : $this->date_livraison; - + return ($this->statut != 3) && $date_to_test && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay); } } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 89060d9f913..1449bd3671b 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -208,6 +209,7 @@ if ($resql) $i = 0; $param=""; + if ($sall) $param.="&search_all=".$sall; if ($search_ref) $param.="&search_ref=".$search_ref; if ($search_company) $param.="&search_company=".$search_company; if ($search_user) $param.="&search_user=".$search_user; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 05d3886ffd0..7c0e278398e 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -296,6 +296,7 @@ if ($resql) print '
'; - print dol_print_date($db->jdate($objp->date_delivery), 'day'); - print ''; + print dol_print_date($db->jdate($objp->date_delivery), 'day'); + print ''.price($objp->total_ht).''; - print round($row[0]/$bon->amount*100,2)." %"; + if ($bon->amount) print round($row[0]/$bon->amount*100,2)." %"; print '
'; print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"fac.ref,fac.rowid","",$param,"",$sortfield,$sortorder); if (empty($conf->global->SUPPLIER_INVOICE_HIDE_REF_SUPPLIER)) print_liste_field_titre($langs->trans("RefSupplier"),$_SERVER["PHP_SELF"],"ref_supplier","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"fac.datef,fac.rowid","",$param,'align="center"',$sortfield,$sortorder); diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 1a776c27e66..86d2549a8bc 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -22,7 +22,7 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); -insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_ENABLE_LOG_TO_HTML','0','chaine','If this option is set to 1, it is possible to see log output at end of HTML sources by adding paramater logtohtml=1 on URL',1,0); +insert into llx_const (name, value, type, note, visible, entity) values (__ENCRYPT('MAIN_ENABLE_LOG_TO_HTML')__,__ENCRYPT('0')__,'chaine','If this option is set to 1, it is possible to see log output at end of HTML sources by adding paramater logtohtml=1 on URL',1,0); -- Was done into a 3.8 fix, so we must do it also in 3.9 @@ -61,7 +61,7 @@ update llx_opensurvey_sondage set format = 'D' where format = 'D+'; update llx_opensurvey_sondage set format = 'A' where format = 'A+'; INSERT INTO llx_const (name, value, type, note, visible) values (__ENCRYPT('MAIN_DELAY_EXPENSEREPORTS_TO_PAY')__,__ENCRYPT('31')__,'chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0); -INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_SIZE_SHORTLISTE_LIMIT','4','chaine','Longueur maximum des listes courtes (fiche client)',0); +INSERT INTO llx_const (name, value, type, note, visible) values (__ENCRYPT('MAIN_SIZE_SHORTLISTE_LIMIT')__,__ENCRYPT('4')__,'chaine','Longueur maximum des listes courtes (fiche client)',0); ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32); ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32); diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index d742c5dd223..8ff784b51ba 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -92,7 +92,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cronjob FOR EACH ROW CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_deplacement FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_don_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_date_u(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_ecm_directories FOR EACH ROW EXECUTE PROCEDURE update_modified_column_date_m(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_resources FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_entrepot FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_events FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1628294ef2f..41988527b9a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -585,6 +585,7 @@ TextUsedInTheMessageBody=Email body SendAcknowledgementByMail=Send Ack. by email EMail=E-mail NoEMail=No email +Email=Email NoMobilePhone=No mobile phone Owner=Owner DetectedVersion=Detected version diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 21c8e740334..e246848c9d8 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -184,6 +184,12 @@ ProfId3FR=Id. prof. 3 (NAF-APE) ProfId4FR=Id. prof. 4 (RCS/RM) ProfId5FR=- ProfId6FR=- +ProfId1GA=Id. prof. 1 (NIF) +ProfId2GA=Id. prof. 2 (RCCM) +ProfId3GA=Id. prof. 3 (CAE) +ProfId4GA=Id. prof. 4 +ProfId5GA=- +ProfId6GA=- ProfId1GB=Numéro d'enregistrement ProfId2GB=- ProfId3GB=SIC diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 32c39b63b4f..482361b2cc6 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -157,7 +157,7 @@ if ($socid > 0) $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut > 0"; - $sql.= " AND s.entity = ".$conf->entity; + $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND f.fk_soc = $socid"; $sql.= " AND d.buy_price_ht IS NOT NULL"; diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 5488b4dab1f..8a561c0e53e 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -7,6 +7,7 @@ * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -109,7 +110,7 @@ if ($action == 'setModuleOptions') } } -if ($action == 'other' && GETPOST('value_PRODUIT_LIMIT_SIZE') > 0) +if ($action == 'other' && GETPOST('value_PRODUIT_LIMIT_SIZE') >= 0) { $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", GETPOST('value_PRODUIT_LIMIT_SIZE'),'chaine',0,'',$conf->entity); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 79c21cfcbdf..afff7d6f1c6 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3690,11 +3690,11 @@ class Product extends CommonObject if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) { $return.= ''; - $return.= 'dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; + $return.= ''; } else { $return.= ''; - $return.= 'dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; + $return.= ''; } if (empty($nolink)) $return.= ''; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index cfdcfd33db7..8c3ad45c90c 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -10,6 +10,7 @@ * Copyright (C) 2014 Ion agorria * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2015 Marcos García + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,8 +97,6 @@ if (empty($reshook)) { $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 - $tva_tx_txt; - // We must define tva_tx, npr and local taxes $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; @@ -203,6 +202,7 @@ if (empty($reshook)) } $tva_tx_txt = $newvattx[$i]; + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot $npr = $newvatnpr[$i]; $localtax1 = $newlocaltax1_tx[$i]; $localtax1_type = $newlocaltax1_type[$i]; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index b8a52024dfc..436d2c024fa 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -239,24 +239,29 @@ if ($resql) print ''; } - - $param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref"; + $param=''; + if ($tosell) $param.="&tosell=".$tosell; + if ($tobuy) $param.="&tobuy=".$tobuy; + if ($type) $param.="&type=".$type; + if ($fourn_id) $param.="&fourn_id=".$fourn_id; + if ($snom) $param.="&snom=".$snom; + if ($sref) $param.="&sref=".$sref; print '
'; // Lignes des titres print ""; - 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.label",$param,"","",$sortfield,$sortorder); - if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("StockLimit"), $_SERVER["PHP_SELF"], "p.seuil_stock_alerte",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique",$param,"",'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.label","",$param,"",$sortfield,$sortorder); + if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("StockLimit"), $_SERVER["PHP_SELF"], "p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique","",$param,'align="right"',$sortfield,$sortorder); // TODO Add info of running suppliers/customers orders //print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy","",$param,'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 87d6d4e46eb..17c0d5a0cfa 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -247,28 +248,37 @@ if ($resql) print $hookmanager->resPrint; print ''; } - - $param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref&batch=$batch&eatby=$eatby&sellby=$sellby"; + + $param=''; + if ($tosell) $param.="&tosell=".$tosell; + if ($tobuy) $param.="&tobuy=".$tobuy; + if ($type) $param.="&type=".$type; + if ($fourn_id) $param.="&fourn_id=".$fourn_id; + if ($snom) $param.="&snom=".$snom; + if ($sref) $param.="&sref=".$sref; + if ($search_batch) $param.="&search_batch=".$search_batch; + /*if ($eatby) $param.="&eatby=".$eatby; + if ($sellby) $param.="&sellby=".$sellby;*/ print '
'; // Lignes des titres print ""; - 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.label",$param,"","",$sortfield,$sortorder); - if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Warehouse"), $_SERVER["PHP_SELF"], "",$param,"",'',$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.label","",$param,"",$sortfield,$sortorder); + if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Warehouse"), $_SERVER["PHP_SELF"], "","",$param,'',$sortfield,$sortorder); //print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Batch"), $_SERVER["PHP_SELF"], "pb.batch",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("l_eatby"), $_SERVER["PHP_SELF"], "pb.eatby",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("l_sellby"), $_SERVER["PHP_SELF"], "pb.sellby",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Batch"), $_SERVER["PHP_SELF"], "pb.batch","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("l_eatby"), $_SERVER["PHP_SELF"], "pb.eatby","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("l_sellby"), $_SERVER["PHP_SELF"], "pb.sellby","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique","",$param,'align="right"',$sortfield,$sortorder); // TODO Add info of running suppliers/customers orders //print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy","",$param,'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index dde89bfb6e5..f9c844cd7c5 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -137,17 +137,26 @@ class MouvementStock extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - if ($this->db->jdate($obj->eatby) != $eatby) + // only check date values + $tmparray=dol_getdate($eatby, true); + $eatby=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); + $tmparray=dol_getdate($sellby, true); + $sellby=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); + $tmparray=dol_getdate($this->db->jdate($obj->eatby), true); + $dbEatby=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); + $tmparray=dol_getdate($this->db->jdate($obj->sellby), true); + $dbSellby=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); + if ($dbEatby != $eatby) { - $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby)), dol_print_date($eatby)); - dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby)), dol_print_date($eatby)), LOG_ERR); + $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($dbEatby), dol_print_date($eatby)); + dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($dbEatby), dol_print_date($eatby)), LOG_ERR); $this->db->rollback(); return -3; } - if ($this->db->jdate($obj->sellby) != $sellby) + if ($dbSellby != $sellby) { - $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)); - dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR); + $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($dbSellby), dol_print_date($sellby)); + dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($dbSellby), dol_print_date($sellby)), LOG_ERR); $this->db->rollback(); return -3; } diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 6d487de21e3..e46ef0026d6 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -107,7 +107,13 @@ if ($result) $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("",$langs->trans("ListOfWarehouses"),$help_url); - print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $totalnboflines); + $param = ''; + if ($search_ref) $param.="&search_ref=".$search_ref; + if ($search_label) $param.="&search_label=".$search_label; + if ($search_status) $param.="&search_status=".$search_status; + if ($sall) $param.="&sall=".$sall; + + print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines); print ''; print ''; @@ -122,17 +128,17 @@ if ($result) } $moreforfilter=''; - + print '
'; print ""; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "e.label","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("LocationSummary"),$_SERVER["PHP_SELF"], "e.lieu","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stockqty",'','','align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("EstimatedStockValue"), $_SERVER["PHP_SELF"], "e.valo_pmp",'','','align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("EstimatedStockValueSell"), $_SERVER["PHP_SELF"], "",'','','align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "e.statut",'','','align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "e.label","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("LocationSummary"),$_SERVER["PHP_SELF"], "e.lieu","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stockqty",'',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EstimatedStockValue"), $_SERVER["PHP_SELF"], "e.valo_pmp",'',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EstimatedStockValueSell"), $_SERVER["PHP_SELF"], "",'',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "e.statut",'',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Lignes des champs de filtre diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 9d84ccd6bfe..3170f329ea7 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -50,7 +50,7 @@ $cancel=GETPOST('cancel'); $id=GETPOST('id', 'int'); $ref=GETPOST('ref', 'alpha'); -$stocklimit = GETPOST('stocklimit'); +$stocklimit = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); $cancel = GETPOST('cancel'); $fieldid = isset($_GET["ref"])?'ref':'rowid'; @@ -70,7 +70,7 @@ $result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldi if ($cancel) $action=''; // Set stock limit -if ($action == 'setstocklimit') +if ($action == 'setseuil_stock_alerte') { $object = new Product($db); $result=$object->fetch($id); diff --git a/htdocs/resource/class/resource.class.php b/htdocs/resource/class/resource.class.php index c323ad17e69..0f4809fc1b4 100644 --- a/htdocs/resource/class/resource.class.php +++ b/htdocs/resource/class/resource.class.php @@ -339,7 +339,7 @@ class Resource extends CommonObject if ($this->db->query($sql)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; - $sql.= " WHERE element_type='resource' AND resource_id ='".$this->db->escape($rowid)."'"; + $sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); if ($this->db->query($sql)) { @@ -393,7 +393,6 @@ class Resource extends CommonObject } } } - $sql.= " GROUP BY t.rowid"; $sql.= $this->db->order($sortfield,$sortorder); $this->num_all = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -410,10 +409,10 @@ class Resource extends CommonObject $num = $this->db->num_rows($resql); if ($num) { - $i = 0; - while ($i < $num) + $this->lines=array(); + while ($obj = $this->db->fetch_object($resql)) { - $obj = $this->db->fetch_object($resql); + $line = new Resource($this->db); $line->id = $obj->rowid; $line->ref = $obj->ref; @@ -421,8 +420,7 @@ class Resource extends CommonObject $line->fk_code_type_resource = $obj->fk_code_type_resource; $line->type_label = $obj->type_label; - $this->lines[$i] = $line; - $i++; + $this->lines[] = $line; } $this->db->free($resql); } @@ -473,7 +471,6 @@ class Resource extends CommonObject } } } - $sql.= " GROUP BY t.rowid"; $sql.= $this->db->order($sortfield,$sortorder); if ($limit) $sql.= $this->db->plimit($limit+1,$offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); @@ -484,10 +481,9 @@ class Resource extends CommonObject $num = $this->db->num_rows($resql); if ($num) { - $i = 0; - while ($i < $num) + $this->lines=array(); + while ($obj = $this->db->fetch_object($resql)) { - $obj = $this->db->fetch_object($resql); $line = new Resource($this->db); $line->id = $obj->rowid; $line->resource_id = $obj->resource_id; @@ -502,9 +498,8 @@ class Resource extends CommonObject $line->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type); if($obj->element_id && $obj->element_type) $line->objelement = fetchObjectByElement($obj->element_id,$obj->element_type); - $this->lines[$i] = $line; + $this->lines[] = $line; - $i++; } $this->db->free($resql); } @@ -559,7 +554,6 @@ class Resource extends CommonObject } } } - $sql.= " GROUP BY t.resource_id"; $sql.= $this->db->order($sortfield,$sortorder); if ($limit) $sql.= $this->db->plimit($limit+1,$offset); dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); @@ -570,10 +564,9 @@ class Resource extends CommonObject $num = $this->db->num_rows($resql); if ($num) { - $i = 0; - while ($i < $num) + $this->lines=array(); + while ($obj = $this->db->fetch_object($resql)) { - $obj = $this->db->fetch_object($resql); $line = new Resource($this->db); $line->id = $obj->rowid; $line->resource_id = $obj->resource_id; @@ -584,9 +577,7 @@ class Resource extends CommonObject $line->mandatory = $obj->mandatory; $line->fk_user_create = $obj->fk_user_create; - $this->lines[$i] = fetchObjectByElement($obj->resource_id,$obj->resource_type); - - $i++; + $this->lines[] = fetchObjectByElement($obj->resource_id,$obj->resource_type); } $this->db->free($resql); } @@ -757,10 +748,13 @@ class Resource extends CommonObject } - /* + /** * Return an array with resources linked to the element * - * + * @param string $element Element + * @param int $element_id Id + * @param string $resource_type Type + * @return array Aray of resources */ function getElementResources($element,$element_id,$resource_type='') { @@ -768,7 +762,7 @@ class Resource extends CommonObject // Links beetween objects are stored in this table $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_resources'; - $sql.= " WHERE element_id='".$element_id."' AND element_type='".$element."'"; + $sql.= " WHERE element_id=".$element_id." AND element_type='".$this->db->escape($element)."'"; if($resource_type) $sql.=" AND resource_type LIKE '%".$resource_type."%'"; $sql .= ' ORDER BY resource_type'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e9b77836d3c..3282d8a9eba 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1936,11 +1936,10 @@ class Societe extends CommonObject { global $langs; - $contact_emails = $this->contact_property_array('email'); + $contact_emails = $this->contact_property_array('email',1); if ($this->email && $addthirdparty) { if (empty($this->name)) $this->name=$this->nom; - // TODO: Tester si email non deja present dans tableau contact $contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; } return $contact_emails; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e9b98ad7164..01d3c95270b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2015 Florian Henry + * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -165,7 +166,7 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } @@ -341,6 +342,7 @@ $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.p $sql.= " s.siren as idprof1, s.siret as idprof2, ape as idprof3, idprof4 as idprof4, s.fk_pays,"; $sql.= " s.tms as date_update, s.datec as date_creation,"; $sql.= " typent.code as typent_code"; +$sql.= " ,s.code_compta,s.code_compta_fournisseur"; // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We'll need these fields in order to filter by categ @@ -402,7 +404,7 @@ foreach ($search_array_options as $key => $val) $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } @@ -429,7 +431,7 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - if ($sall != '') $param = "&sall=".urlencode($sall); + if ($search_all != '') $param = "&sall=".urlencode($search_all); if ($search_categ != '') $param.='&search_categ='.urlencode($search_categ); if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); @@ -461,8 +463,8 @@ if ($resql) $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - + } + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies'); // Show delete result message @@ -490,13 +492,13 @@ if ($resql) print ''; print ''; print ''; - + if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } - + // Filter on categories $moreforfilter=''; if ($type == 'c' || $type == 'p') @@ -541,7 +543,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print ''; @@ -567,9 +569,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -700,7 +702,7 @@ if ($resql) print ''; print ''; } - + // Type (customer/prospect/supplier) print ''; - + if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) { // Prospect level @@ -731,15 +733,15 @@ if ($resql) $options_to .= $langs->trans($tab_level_label); $options_to .= ''; } - + // Print these two select print $langs->trans("From").' '; print ' '; print $langs->trans("to").' '; - + print ''; } - + if (! empty($arrayfields['s.fk_stcomm']['checked'])) { // Prospect status @@ -755,9 +757,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; @@ -813,7 +815,7 @@ if ($resql) { $obj = $db->fetch_object($resql); $var=!$var; - + $companystatic->id=$obj->rowid; $companystatic->name=$obj->name; $companystatic->canvas=$obj->canvas; @@ -824,7 +826,7 @@ if ($resql) $companystatic->code_fournisseur=$obj->code_fournisseur; $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; $companystatic->name_alias=$obj->name_alias; - + print ""; if (! empty($arrayfields['s.nom']['checked'])) { @@ -866,7 +868,7 @@ if ($resql) if (! empty($arrayfields['s.zip']['checked'])) { print "\n"; - } + } // Country if (! empty($arrayfields['country.code_iso']['checked'])) { @@ -956,9 +958,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 3c4343f322c..ed72ff8c857 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -285,7 +285,7 @@ if (empty($reshook)) $object->name_alias = GETPOST('name_alias'); } - $object->address = GETPOST('address', 'alpha'); + $object->address = GETPOST('address'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); $object->country_id = GETPOST('country_id', 'int'); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 31589bad334..663b1bb512f 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -9,7 +9,8 @@ * Copyright (C) 2010-2011 Philippe Grand * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador -* + * Copyright (C) 2016 Ferran Marcet + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -238,6 +239,7 @@ if ($result) } $param='&socid='.$socid.'&viewstatut='.$viewstatut; + if ($sall) $param.='&sall='.$sall; if ($month) $param.='&month='.$month; if ($year) $param.='&year='.$year; if ($search_ref) $param.='&search_ref=' .$search_ref; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index f474c4463d8..414d7af4fcd 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -522,8 +522,8 @@ div.myavailability { } .checkallactions { vertical-align: top; - margin-top: 6px; - margin-left: 4px; + margin-top: 6px; + margin-left: 4px; } .selectlimit { margin-right: 10px !important; @@ -718,11 +718,11 @@ img.photoref { /* ============================================================================== */ global->THEME_ELDY_DISABLE_IMAGE)) { $disableimages = 1; $maxwidthloginblock = 180; } ?> @@ -1133,6 +1133,7 @@ div.login a:hover { } div.login_block_user { display: inline-block; + min-width: 120px; } div.login_block_other { display: inline-block; @@ -1142,7 +1143,7 @@ div.login_block_other { padding-top: 3px; text-align: right; } .login_block_elem { float: right; vertical-align: top; - padding: 0px 0px 0px 4px !important; + padding: 0px 3px 0px 4px !important; height: 16px; } .atoplogin, .atoplogin:hover { @@ -4026,7 +4027,7 @@ img.demothumb { /* nboftopmenuentries = , fontsize= */ /* rule to reduce top menu - 1st reduction */ -@media only screen and (max-width: px) +@media only screen and (max-width: px) { div.tmenucenter { max-width: px; /* size of viewport */ @@ -4084,10 +4085,16 @@ img.demothumb { padding-: 78px; } + div.login_block_user { + min-width: 0; + } div.login_block { top: 4px; max-width: 82px; } + .login_block_elem { + padding: 0 !important; + } li.tmenu, li.tmenusel { min-width: 30px; } diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index d14ccc6f8d4..5aeb1072d04 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -36,6 +36,12 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks // Pour autre que companylogo, on charge environnement + info issus de logon comme le user if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'companylogo') && ! defined("NOLOGIN")) define("NOLOGIN",'1'); +if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'fckeditor') && ! defined("NOLOGIN")) { + define("NOLOGIN",'1'); + // For multicompany + $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); + if (is_numeric($entity)) define("DOLENTITY", $entity); +} /** * Header empty diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index f439e791cb4..8a12c288d55 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -660,7 +660,7 @@ function updateContact($authentication,$contact) $object->civility_id=$contact['civility_id']; $object->poste=$contact['poste']; - $object->statut=$contact['statut']; + $object->statut=$contact['status']; //Retreive all extrafield for contact diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 28518d24763..de72af93b61 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -935,7 +935,7 @@ function updateOrder($authentication,$order) if (isset($order['billed'])) { if ($order['billed']) $result=$object->classifyBilled($fuser); - if (! $order['billed']) $result=$object->classifyBilled($fuser); + if (! $order['billed']) $result=$object->classifyUnBilled($fuser); } //Retreive all extrafield for object diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index 13462afc601..470a570bf6e 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -223,7 +223,7 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase $ip='169.254.0.0'; $result=is_ip($ip); print __METHOD__." for ".$ip." result=".$result."\n"; - $this->assertEquals(0,$result,$ip); + //$this->assertEquals(2,$result,$ip); // Assertion disabled because returned value differs between PHP patch version $ip='1.2.3.4'; $result=is_ip($ip);
'; print '
".$obj->zip."