diff --git a/ChangeLog b/ChangeLog index d97bfe9a9ce..409c885050f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -133,6 +133,12 @@ Fix: [ bug #1393 ] PHP Warning when creating a supplier invoice. Fix: [ bug #1399 ] [pgsql] Silent warning when setting a propal as "facturée" in propal.php Fix: When number reach 9999 with default numbering module, next number will be 10000 instead of 0000 and error. +Fix: element page on project give wrong href link. +Fix: [ bug #1397 ] Filter by supplier orders with status Draft does not filter. +Fix: [ bug #1388 ] Wrong date when invoicing several orders. +Fix: [ bug #1411 ] Unable to set an expedition note if invoices module is not enabled. +Fix: [ bug #1407 ] Rouget pdf overlapped when using tracking number and public notes. +Fix: [ bug #1405 ] Rouget PDF expedition incorrect when two expeditions under the same commande ***** ChangeLog for 3.5.2 compared to 3.5.1 ***** Fix: Can't add user for a task. @@ -220,6 +226,7 @@ Fix: [ bug #1306 ] Fatal error when adding an external calendar. New: Added es_CL language Fix: Margin tabs bad data show Fix: [ bug #1318 ] Problem with enter key when adding an existing product to a customer invoice. +Fix: [ bug #1410 ] Add customer order line asks for required Unit Price but doesn't interrupt the creation of the line ***** ChangeLog for 3.5 compared to 3.4.* ***** For users: diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 7cbb0ce0370..371854410b0 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -30,8 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -if (!$user->admin) - accessforbidden(); +if (!$user->admin) accessforbidden(); $langs->load("agenda"); $langs->load("admin"); @@ -63,7 +62,7 @@ if ($actionsave) // Save agendas while ($i <= $MAXAGENDA) { - $name=trim(GETPOST('agenda_ext_name'.$i),'alpha'); + $name=trim(GETPOST('agenda_ext_name'.$i,'alpha')); $src=trim(GETPOST('agenda_ext_src'.$i,'alpha')); $color=trim(GETPOST('agenda_ext_color'.$i,'alpha')); if ($color=='-1') $color=''; @@ -76,7 +75,7 @@ if ($actionsave) break; } - //print 'color='.$color; + //print '-name='.$name.'-color='.$color; $res=dolibarr_set_const($db,'AGENDA_EXT_NAME'.$i,$name,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; $res=dolibarr_set_const($db,'AGENDA_EXT_SRC'.$i,$src,'chaine',0,'',$conf->entity); @@ -218,8 +217,7 @@ print ''; print '
'; print '
'; - -print "trans("Save")."\">"; +print "trans("Save")."\">"; print "
"; print "\n"; diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 590502f617d..27c447e7c15 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -86,18 +86,35 @@ print '
'; // OPCode cache print '
'; print ''.$langs->trans("OPCodeCache").': '; -$test1=function_exists('xcache_info'); -if ($test1) +$foundcache=0; +$test=function_exists('xcache_info'); +if (! $foundcache && $test) { + $foundcache++; print img_picto('','tick.png').' '.$langs->trans("XCacheInstalled"); print ' '.$langs->trans("MoreInformation").' Xcache admin page'; } -else +$test=function_exists('eaccelerator_info'); +if (! $foundcache && $test) { - $test2=function_exists('eaccelerator_info'); - if ($test2) print img_picto('','tick.png').' '.$langs->trans("EAcceleratorInstalled"); - else print $langs->trans("NoOPCodeCacheFound"); + $foundcache++; + print img_picto('','tick.png').' '.$langs->trans("EAcceleratorInstalled"); } +$test=function_exists('apc_cache_info'); +if (! $foundcache && $test) +{ + //var_dump(apc_cache_info()); + if (ini_get('apc.enabled')) + { + $foundcache++; + print img_picto('','tick.png').' '.$langs->trans("APCInstalled"); + } + else + { + print img_picto('','warning').' '.$langs->trans("APCCacheInstalledButDisabled"); + } +} +if (! $foundcache) print $langs->trans("NoOPCodeCacheFound"); print '
'; // HTTPCacheStaticResources diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index bca56b811b2..717d7269fa2 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -56,14 +56,13 @@ class ICal { $this->file = $file; $file_text=''; - + $tmparray=file($file); if (is_array($tmparray)) { $file_text = join("", $tmparray); //load file - $file_text = preg_replace("/[\r\n]{1,} ([:;])/","\\1",$file_text); + $file_text = preg_replace("/[\r\n]{1,} /","",$file_text); } - return $file_text; // return all text } @@ -115,6 +114,7 @@ class ICal { // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin list($key, $value) = $this->retun_key_value($text); + //var_dump($text.' -> '.$key.' - '.$value); switch ($text) // search special string { @@ -165,6 +165,8 @@ class ICal } } } + + //var_dump($this->cal); return $this->cal; } @@ -236,6 +238,7 @@ class ICal */ function retun_key_value($text) { + /* preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches); if (empty($matches)) @@ -246,8 +249,8 @@ class ICal { $matches = array_splice($matches, 1, 2); return $matches; - } - + }*/ + return explode(':',$text,2); } /** diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 0f21d190773..92b87d94ad1 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -146,9 +146,11 @@ if (empty($conf->global->AGENDA_DISABLE_EXT) && $conf->global->AGENDA_EXT_NB > 0 $source='AGENDA_EXT_SRC'.$i; $name='AGENDA_EXT_NAME'.$i; $color='AGENDA_EXT_COLOR'.$i; + $buggedfile='AGENDA_EXT_BUGGEDFILE'.$i; if (! empty($conf->global->$source) && ! empty($conf->global->$name)) { - $listofextcals[]=array('src'=>$conf->global->$source,'name'=>$conf->global->$name,'color'=>$conf->global->$color); + // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' + $listofextcals[]=array('src'=>$conf->global->$source,'name'=>$conf->global->$name,'color'=>$conf->global->$color,'buggedfile'=>(isset($conf->global->buggedfile)?$conf->global->buggedfile:0)); } } } @@ -527,9 +529,11 @@ if (count($listofextcals)) $url=$extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics $namecal = $extcal['name']; $colorcal = $extcal['color']; - //print "url=".$url." namecal=".$namecal." colorcal=".$colorcal; + $buggedfile = $extcal['buggedfile']; + //print "url=".$url." namecal=".$namecal." colorcal=".$colorcal." buggedfile=".$buggedfile; $ical=new ICal(); $ical->parse($url); + // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... //var_dump($ical->cal); exit; $icalevents=array(); @@ -643,6 +647,8 @@ if (count($listofextcals)) // Loop on each entry into cal file to know if entry is qualified and add an ActionComm into $eventarray foreach($icalevents as $icalevent) { + //var_dump($icalevent); + //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'
';exit; if (! empty($icalevent['RRULE'])) continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. @@ -659,12 +665,36 @@ if (count($listofextcals)) $event->fulldayevent=true; $addevent=true; } - elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array) + elseif (!is_array($icalevent['DTSTART'])) // not fullday event (DTSTART is not array. It is a value like '19700101T000000Z' for 00:00 in greenwitch) { $datestart=$icalevent['DTSTART']; $dateend=$icalevent['DTEND']; $addevent=true; } + elseif (isset($icalevent['DTSTART']['unixtime'])) // File contains a local timezone + a TZ (for example when using bluemind) + { + $datestart=$icalevent['DTSTART']['unixtime']; + $dateend=$icalevent['DTEND']['unixtime']; + // $buggedfile is set to uselocalandtznodaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtznodaylight' + if ($buggedfile === 'uselocalandtznodaylight') // unixtime is a local date that does not take daylight into account, TZID is +1 for example for 'Europe/Paris' in summer instead of 2 + { + // TODO + } + // $buggedfile is set to uselocalandtzdaylight if conf->global->AGENDA_EXT_BUGGEDFILEx = 'uselocalandtzdaylight' (for example with bluemind) + if ($buggedfile === 'uselocalandtzdaylight') // unixtime is a local date that does take daylight into account, TZID is +2 for example for 'Europe/Paris' in summer + { + $localtzs = new DateTimeZone(preg_replace('/"/','',$icalevent['DTSTART']['TZID'])); + $localtze = new DateTimeZone(preg_replace('/"/','',$icalevent['DTEND']['TZID'])); + $localdts = new DateTime(dol_print_date($datestart,'dayrfc','gmt'), $localtzs); + $localdte = new DateTime(dol_print_date($dateend,'dayrfc','gmt'), $localtze); + $tmps=-1*$localtzs->getOffset($localdts); + $tmpe=-1*$localtze->getOffset($localdte); + $datestart+=$tmps; + $dateend+=$tmpe; + //var_dump($datestart); + } + $addevent=true; + } if ($addevent) { diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 4a6b04f54fb..efed0298f52 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1157,7 +1157,7 @@ if ($action == 'create') { // Date print '' . $langs->trans('Date') . ''; - $form->select_date('', '', '', '', '', "addprop"); + $form->select_date('', '', '', '', '', "addprop", 1, 1); print ''; // Validaty duration @@ -1191,10 +1191,9 @@ if ($action == 'create') { $syear = date("Y", $tmpdte); $smonth = date("m", $tmpdte); $sday = date("d", $tmpdte); - $form->select_date($syear . "-" . $smonth . "-" . $sday, 'liv_', '', '', '', "addprop"); + $form->select_date($syear."-".$smonth."-".$sday, 'liv_', '', '', '', "addprop"); } else { - $datepropal = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : 0; - $form->select_date($datepropal, 'liv_', '', '', '', "addprop"); + $form->select_date(-1, 'liv_', '', '', '', "addprop", 1, 1); } print ''; @@ -1247,8 +1246,9 @@ if ($action == 'create') { print ''; } - print ''; - if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) { + if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '
'; + if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) + { // For backward compatibility print ''; print ''; @@ -1311,13 +1311,11 @@ if ($action == 'create') { print ''; print ''; } - print "
%
"; } print ''; } - print ''; - print '
'; + if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '
'; $langs->load("bills"); print '
'; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 73d1cb720d4..ba0a49f2772 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -285,7 +285,7 @@ if ($result) print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'p.datep','',$param, 'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('DateEndPropalShort'),$_SERVER["PHP_SELF"],'dfv','',$param, 'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Author'),$_SERVER["PHP_SELF"],'u.login','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Author'),$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; @@ -301,6 +301,7 @@ if ($result) print ''; print ''; print ''; + // Date print ''; //print $langs->trans('Month').': '; print ''; @@ -309,11 +310,12 @@ if ($result) $formother->select_year($syear,'year',1, 20, 5); print ''; print ' '; + // Amount print ''; print ''; print ''; - - print ''; + // Author + print ''; print ''; print ''; print ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 086dc5a8073..e2b0f5506fb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1387,7 +1387,7 @@ class Commande extends CommonOrder $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); $this->fetch_optionals($this->id,$extralabels); - $this->db->free(); + $this->db->free($result); /* * Lines diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 2b326858c48..7c1f0d30d25 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -476,7 +476,7 @@ else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) { // Add a new line else if ($action == 'addline' && $user->rights->commande->creer) { $langs->load('errors'); - $error = false; + $error = 0; // Set if we used free entry or predefined product $predef=''; @@ -1319,13 +1319,13 @@ if ($action == 'create' && $user->rights->commande->creer) { $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); $soc = $objectsrc->client; - $cond_reglement_id = (! empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (! empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 1)); - $mode_reglement_id = (! empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (! empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); - $availability_id = (! empty($objectsrc->availability_id) ? $objectsrc->availability_id : (! empty($soc->availability_id) ? $soc->availability_id : 0)); - $demand_reason_id = (! empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (! empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); - $remise_percent = (! empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (! empty($soc->remise_percent) ? $soc->remise_percent : 0)); - $remise_absolue = (! empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (! empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : 0; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; $datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); @@ -1335,17 +1335,19 @@ if ($action == 'create' && $user->rights->commande->creer) { // Object source contacts list $srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1); } - } else { - $cond_reglement_id = $soc->cond_reglement_id; - $mode_reglement_id = $soc->mode_reglement_id; - $availability_id = $soc->availability_id; - $demand_reason_id = $soc->demand_reason_id; - $remise_percent = $soc->remise_percent; - $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : 0; - $projectid = 0; } - $absolute_discount = $soc->getAvailableDiscounts(); + else + { + $cond_reglement_id = $soc->cond_reglement_id; + $mode_reglement_id = $soc->mode_reglement_id; + $availability_id = $soc->availability_id; + $demand_reason_id = $soc->demand_reason_id; + $remise_percent = $soc->remise_percent; + $remise_absolue = 0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + $projectid = 0; + } + $absolute_discount=$soc->getAvailableDiscounts(); $nbrow = 10; @@ -1414,12 +1416,11 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; // Date de livraison - print "" . $langs->trans("DeliveryDate") . ''; - if (empty($datedelivery)) { - if (! empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) - $datedelivery = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); - else - $datedelivery = empty($conf->global->MAIN_AUTOFILL_DATE) ? - 1 : 0; + print "".$langs->trans("DeliveryDate").''; + if (empty($datedelivery)) + { + if (! empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); + else $datedelivery=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; } $form->select_date($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1); print ""; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index bfdf2dbb5ca..0036aa430f1 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -373,7 +373,7 @@ if ($action == 'create' && empty($mesgs)) $remise_percent = $soc->remise_percent; } $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; $absolute_discount=$soc->getAvailableDiscounts(); print '
'; @@ -413,7 +413,7 @@ if ($action == 'create' && empty($mesgs)) // Date invoice print ''.$langs->trans('Date').''; - $html->select_date(0,'','','','',"add",1,1); + $html->select_date('','','','','',"add",1,1); print ''; // Payment term print ''.$langs->trans('PaymentConditionsShort').''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 316c589f046..c77aea4178e 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1871,10 +1871,12 @@ if ($action == 'create') $ref_int = (! empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); $soc = $objectsrc->thirdparty; - $cond_reglement_id = (! empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (! empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 1)); - $mode_reglement_id = (! empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (! empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); - $remise_percent = (! empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (! empty($soc->remise_percent) ? $soc->remise_percent : 0)); - $remise_absolue = (! empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (! empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + + $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; // Replicate extrafields $objectsrc->fetch_optionals($originid); @@ -1884,11 +1886,11 @@ if ($action == 'create') } else { - $cond_reglement_id = $soc->cond_reglement_id; - $mode_reglement_id = $soc->mode_reglement_id; - $remise_percent = $soc->remise_percent; - $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : ''; // Do not set 0 here (0 for a date is 1970) + $cond_reglement_id = $soc->cond_reglement_id; + $mode_reglement_id = $soc->mode_reglement_id; + $remise_percent = $soc->remise_percent; + $remise_absolue = 0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; // Do not set 0 here (0 for a date is 1970) } $absolute_discount = $soc->getAvailableDiscounts(); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index b99467c20f0..b6065909ade 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -363,7 +363,8 @@ class FormOther $sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut, u.login"; $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")"; - if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.fk_societe = ".($user->societe_id?$user->societe_id:0); + if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.rowid = ".$user->id; + if (! empty($user->societe_id)) $sql_usr.=" AND u.fk_societe = ".$user->societe_id; // Add existing sales representatives of thirdparty of external user if (empty($user->rights->user->user->lire) && $user->societe_id) { diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 9e0d78118b0..2c371d4afcd 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -194,6 +194,7 @@ class FormProjets if (!empty($this->societe->id)) { $sql.= " AND fk_soc=".$this->societe->id; } + $sql.= ' AND entity='.$conf->entity; $sql.= " ORDER BY ref DESC"; dol_syslog(get_class($this).'::select_element sql='.$sql,LOG_DEBUG); diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index be898d8a114..ab9d6e5850e 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -825,8 +825,16 @@ class DoliDBMysql extends DoliDB $resql=$this->query($sql); if (! $resql) { - dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_ERR); - return -1; + if ($this->lasterrno != 'DB_ERROR_USER_ALREADY_EXISTS') + { + dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_ERR); + return -1; + } + else + { + // If user already exists, we continue to set permissions + dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_WARNING); + } } $sql = "GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'"; dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 09199f84318..40061a4fa1a 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -829,8 +829,16 @@ class DoliDBMysqli extends DoliDB $resql=$this->query($sql); if (! $resql) { - dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_ERR); - return -1; + if ($this->lasterrno != 'DB_ERROR_USER_ALREADY_EXISTS') + { + dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_ERR); + return -1; + } + else + { + // If user already exists, we continue to set permissions + dol_syslog(get_class($this)."::DDLCreateUser sql=".$sql, LOG_WARNING); + } } $sql = "GRANT ALL PRIVILEGES ON ".$this->escape($dolibarr_main_db_name).".* TO '".$this->escape($dolibarr_main_db_user)."'@'".$this->escape($dolibarr_main_db_host)."' IDENTIFIED BY '".$this->escape($dolibarr_main_db_pass)."'"; dol_syslog(get_class($this)."::DDLCreateUser", LOG_DEBUG); // No sql to avoid password in log diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index d2d380ad45c..bb55e57f86b 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -39,7 +39,7 @@ * @param string $filterd Filter of done by user * @param int $pid Product id * @param int $socid Third party id - * @param array $showextcals Array with list of external calendars, or -1 to show no legend + * @param array $showextcals Array with list of external calendars (used to show links to select calendar), or -1 to show no legend * @param string $actioncode Preselected value of actioncode for filter on type * @return void */ @@ -136,7 +136,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print '});' . "\n"; print '' . "\n"; print ''; - if (! empty($conf->global->MAIN_JS_SWITCH_AGENDA)) + if (! empty($conf->use_javascript_ajax)) { if (count($showextcals) > 0) { @@ -147,7 +147,10 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index b35f89dd1a7..04164a38579 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -317,7 +317,7 @@ foreach ($listofreferent as $key => $value) } if ($key == 'invoice' && ! empty($conf->facture->enabled) && $user->rights->facture->creer) { - print ''.$langs->trans("AddCustomerInvoice").''; + print ''.$langs->trans("AddCustomerInvoice").''; } } if ($project->societe->fournisseur) diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index 94e05ece06a..d019a629bdd 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -126,7 +126,7 @@ print ''; print ''; print "\n"; -if (count($tasksarray) > (empty($conf->global->PROJECT_MAX_NB_TASKS)?1000:$conf->global->PROJECT_MAX_NB_TASKS)) +if (count($tasksarray) > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)) { print ''; print '
'; print '' . "\n"; print ' ' . $val ['name']; @@ -434,9 +437,9 @@ function actions_prepare_head($object) $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; - + complete_head_from_modules($conf,$langs,$object,$head,$h,'action'); - + complete_head_from_modules($conf,$langs,$object,$head,$h,'action','remove'); return $head; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a8609af05bd..a22c38834cf 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3694,6 +3694,7 @@ function dol_textishtml($msg,$option=0) elseif (preg_match('/<(br|div|font|img|li|span|strong|table)>/i',$msg)) return true; elseif (preg_match('/<(br|div|font|img|li|span|strong|table)\s+[^<>\/]*>/i',$msg)) return true; elseif (preg_match('/<(br|div|font|img|li|span|strong|table)\s+[^<>\/]*\/>/i',$msg)) return true; + elseif (preg_match('//i',$msg)) return true; elseif (preg_match('/&[A-Z0-9]{1,6};/i',$msg)) return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) elseif (preg_match('/&#[0-9]{2,3};/i',$msg)) return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) return false; @@ -4588,4 +4589,3 @@ function natural_search($fields, $value) } return " AND " . ($end > 1? '(' : '') . $res; } - diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 6f8a86389bc..09b39f22812 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1036,10 +1036,10 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (empty($hideref)) { - if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref + if ($issupplierline) $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref else $ref_prodserv = $prodser->ref; // Show local ref only - $ref_prodserv .= " - "; + if (! empty($libelleproduitservice)) $ref_prodserv .= " - "; } $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 35b3f78c5e7..e3a6f79210d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -773,16 +773,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Suppliers if (! empty($conf->societe->enabled) && ! empty($conf->fournisseur->enabled)) { - if (! empty($conf->facture->enabled)) - { - $langs->load("bills"); - $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); - $newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer); - $newmenu->add("/fourn/facture/impayees.php", $langs->trans("Unpaid"),1,$user->rights->fournisseur->facture->lire); - $newmenu->add("/fourn/facture/paiement.php", $langs->trans("Payments"),1,$user->rights->fournisseur->facture->lire); + $langs->load("bills"); + $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); + $newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer); + $newmenu->add("/fourn/facture/impayees.php", $langs->trans("Unpaid"),1,$user->rights->fournisseur->facture->lire); + $newmenu->add("/fourn/facture/paiement.php", $langs->trans("Payments"),1,$user->rights->fournisseur->facture->lire); - $newmenu->add("/compta/facture/stats/index.php?leftmenu=suppliers_bills&mode=supplier", $langs->trans("Statistics"),1,$user->rights->fournisseur->facture->lire); - } + $newmenu->add("/compta/facture/stats/index.php?leftmenu=suppliers_bills&mode=supplier", $langs->trans("Statistics"),1,$user->rights->fournisseur->facture->lire); } // Orders diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index d75e8d203e5..30c753bf1dc 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Marcos García * * 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 @@ -179,9 +180,10 @@ class pdf_rouget extends ModelePdfExpedition $tab_height = 130; $tab_height_newpage = 150; - if (! empty($object->note_public) || ! empty($object->tracking_number)) + if (! empty($object->note_public) || (! empty($object->tracking_number) && ! empty($object->shipping_method_id))) { $tab_top = 88; + $tab_top_alt = $tab_top; // Tracking number if (! empty($object->tracking_number)) @@ -196,7 +198,9 @@ class pdf_rouget extends ModelePdfExpedition $label=$outputlangs->trans("LinkToTrackYourPackage")."
"; $label.=$outputlangs->trans("SendingMethod".strtoupper($code))." :"; $pdf->SetFont('','B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $label." ".$object->tracking_url, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 7, $this->posxdesc-1, $tab_top-1, $label." ".$object->tracking_url, 0, 1, false, true, 'L'); + + $tab_top_alt += 7; } } } @@ -205,7 +209,7 @@ class pdf_rouget extends ModelePdfExpedition if (! empty($object->note_public)) { $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); } $nexY = $pdf->GetY(); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 549a9caed32..e10a39128a2 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -444,7 +444,7 @@ class FactureFournisseur extends CommonInvoice */ function fetch_lines() { - $sql = 'SELECT f.rowid, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx, f.tva'; + $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx, f.tva'; $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; @@ -452,7 +452,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid'; $sql.= ' WHERE fk_facture_fourn='.$this->id; - dol_syslog("FactureFournisseur::fetch_lines sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_lines sql=".$sql, LOG_DEBUG); $resql_rows = $this->db->query($sql); if ($resql_rows) { @@ -467,11 +467,11 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i] = new stdClass(); $this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->description = $obj->description; - $this->lines[$i]->ref = $obj->product_ref; // TODO deprecated $this->lines[$i]->product_ref = $obj->product_ref; // Internal reference - //$this->lines[$i]->ref_fourn = $obj->ref_fourn; // Reference fournisseur du produit - $this->lines[$i]->libelle = $obj->label; // Label du produit - $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit + $this->lines[$i]->ref = $obj->product_ref; // deprecated. + $this->lines[$i]->ref_supplier = $obj->ref_supplier; // Reference product supplier TODO Rename field ref to ref_supplier into table llx_facture_fourn_det and llx_commande_fournisseurdet and update fields it into updateline + $this->lines[$i]->libelle = $obj->label; // This field may contains label of product (when invoice create from order) + $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit $this->lines[$i]->pu_ht = $obj->pu_ht; $this->lines[$i]->pu_ttc = $obj->pu_ttc; $this->lines[$i]->tva_tx = $obj->tva_tx; @@ -498,7 +498,7 @@ class FactureFournisseur extends CommonInvoice else { $this->error=$this->db->error(); - dol_syslog('FactureFournisseur::fetch_lines: Error '.$this->error,LOG_ERR); + dol_syslog(get_class($this).'::fetch_lines: Error '.$this->error,LOG_ERR); return -3; } } @@ -1059,6 +1059,8 @@ class FactureFournisseur extends CommonInvoice * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,idprod) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue). * + * FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order. + * * @param string $desc Description de la ligne * @param double $pu Prix unitaire (HT ou TTC selon price_base_type, > 0 even for credit note) * @param double $txtva Taux de tva force, sinon -1 @@ -1152,7 +1154,7 @@ class FactureFournisseur extends CommonInvoice * Update a line detail into database * * @param int $id Id of line invoice - * @param string $label Description of line + * @param string $desc Description of line * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) * @param double $vatrate VAT Rate * @param double $txlocaltax1 LocalTax1 Rate @@ -1166,9 +1168,9 @@ class FactureFournisseur extends CommonInvoice * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function updateline($id, $label, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false) + function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false) { - dol_syslog(get_class($this)."::updateline $id,$label,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG); + dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $pu = price2num($pu); @@ -1194,7 +1196,7 @@ class FactureFournisseur extends CommonInvoice $localtaxes_type=getLocalTaxesFromRate($vatrate,0,$this->thirdparty); - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty,$localtaxes_type); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -1217,7 +1219,7 @@ class FactureFournisseur extends CommonInvoice } $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; - $sql.= " description ='".$this->db->escape($label)."'"; + $sql.= " description ='".$this->db->escape($desc)."'"; $sql.= ", pu_ht = ".price2num($pu_ht); $sql.= ", pu_ttc = ".price2num($pu_ttc); $sql.= ", qty = ".price2num($qty); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 4aeb265a41c..b642926f802 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -40,8 +40,13 @@ class ProductFournisseur extends Product var $product_fourn_price_id; // id of ligne product-supplier var $id; // product id - var $fourn_ref; // ref supplier - var $fourn_qty; // quantity for price + var $fourn_ref; // deprecated + var $ref_supplier; // ref supplier (can be set by get_buyprice) + var $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) + + var $fourn_qty; // quantity for price (can be set by get_buyprice) + var $fourn_pu; // unit price for quantity (can be set by get_buyprice) + var $fourn_price; // price for quantity var $fourn_remise_percent; // discount for quantity (percent) var $fourn_remise; // discount for quantity (amount) diff --git a/htdocs/fourn/commande/liste.php b/htdocs/fourn/commande/liste.php index f6f634ec7ea..9e0c12ecf5f 100644 --- a/htdocs/fourn/commande/liste.php +++ b/htdocs/fourn/commande/liste.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2014 Marcos García * * 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 @@ -115,7 +116,8 @@ if ($sall) } if ($socid) $sql.= " AND s.rowid = ".$socid; -if (GETPOST('statut')!='') +//Required triple check because statut=0 means draft filter +if (GETPOST('statut', 'int') !== '') { $sql .= " AND fk_statut IN (".GETPOST('statut').")"; } diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index ccd32ce1e68..e70d78d1ea6 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -363,6 +363,7 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. $result = $object->addline( $desc, $lines[$i]->subprice, @@ -604,6 +605,7 @@ elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer) $type = $productsupplier->type; + // TODO Save the product supplier ref into database into field ref_supplier (must rename field ref into ref_supplier first) $result=$object->addline($desc, $productsupplier->fourn_pu, $tvatx, $localtax1tx, $localtax2tx, $qty, $idprod, $remise_percent, '', '', 0, $npr); } if ($idprod == -2 || $idprod == 0) @@ -1150,10 +1152,10 @@ if ($action == 'create') $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); $datedue=($datetmp==''?-1:$datetmp); } @@ -1163,7 +1165,7 @@ if ($action == 'create') $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); $datedue=($datetmp==''?-1:$datetmp); } diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php index 40799e2bcb9..4b2c61c02a5 100644 --- a/htdocs/fourn/facture/impayees.php +++ b/htdocs/fourn/facture/impayees.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -if (! $user->rights->facture->lire) accessforbidden(); +if (! $user->rights->fournisseur->facture->lire) accessforbidden(); $langs->load("companies"); $langs->load("bills"); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 8502e13834d..f02e48a9be5 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -243,7 +243,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $object->fetch($facid); $datefacture=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datefacture); + $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datefacture); $sql = 'SELECT s.nom, s.rowid as socid,'; $sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total'; diff --git a/htdocs/holiday/admin/holiday.php b/htdocs/holiday/admin/holiday.php index 174adbdf725..2b265711fa1 100644 --- a/htdocs/holiday/admin/holiday.php +++ b/htdocs/holiday/admin/holiday.php @@ -60,18 +60,18 @@ $cp = new Holiday($db); if ($action == "add") { $message = ''; - $error = false; + $error = 0; // Option du groupe de validation /*if (!$cp->updateConfCP('userGroup',$_POST['userGroup'])) { - $error = true; + $error++; }*/ // Option du délai pour faire une demande de congés payés if (!$cp->updateConfCP('delayForRequest',$_POST['delayForRequest'])) { - $error = true; + $error++; } // Option du nombre de jours à ajouter chaque mois @@ -79,67 +79,69 @@ if ($action == "add") if(!$cp->updateConfCP('nbHolidayEveryMonth',$nbHolidayEveryMonth)) { - $error = true; + $error++; } // Option du nombre de jours pour un mariage $OptMariageCP = price2num($_POST['OptMariage'],5); if(!$cp->updateConfCP('OptMariage',$OptMariageCP)) { - $error = true; + $error++; } // Option du nombre de jours pour un décés d'un proche $OptDecesProcheCP = price2num($_POST['OptDecesProche'],5); if(!$cp->updateConfCP('OptDecesProche',$OptDecesProcheCP)) { - $error = true; + $error++; } // Option du nombre de jours pour un mariage d'un enfant $OptMariageProcheCP = price2num($_POST['OptMariageProche'],5); if(!$cp->updateConfCP('OptMariageProche',$OptMariageProcheCP)) { - $error = true; + $error++; } // Option du nombre de jours pour un décés d'un parent $OptDecesParentsCP = price2num($_POST['OptDecesParents'],5); if(!$cp->updateConfCP('OptDecesParents',$OptDecesParentsCP)) { - $error = true; + $error++; } // Option pour avertir le valideur si délai de demande incorrect if(isset($_POST['AlertValidatorDelay'])) { if(!$cp->updateConfCP('AlertValidatorDelay','1')) { - $error = true; + $error++; } } else { if(!$cp->updateConfCP('AlertValidatorDelay','0')) { - $error = true; + $error++; } } // Option pour avertir le valideur si solde des congés de l'utilisateur inccorect if(isset($_POST['AlertValidatorSolde'])) { if(!$cp->updateConfCP('AlertValidatorSolde','1')) { - $error = true; + $error++; } } else { if(!$cp->updateConfCP('AlertValidatorSolde','0')) { - $error = true; + $error++; } } // Option du nombre de jours à déduire pour 1 jour de congés $nbHolidayDeducted = price2num($_POST['nbHolidayDeducted'],2); - if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted)) { - $error = true; + if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted)) + { + $error++; } - if ($error) { + if ($error) + { $message = '
'.$langs->trans('ErrorUpdateConfCP').'
'; } else { $message = '
'.$langs->trans('UpdateConfCPOK').'
'; @@ -151,8 +153,8 @@ if ($action == "add") $result = $db->query($sql); $num = $db->num_rows($sql); - - if($num < 1) { + if($num < 1) + { $cp->createCPusers(); $message.= '
'.$langs->trans('AddCPforUsers').'
'; } @@ -202,7 +204,7 @@ elseif ($action == 'create_event') } elseif($action == 'event' && isset($_POST['update_event'])) { - $error = false; + $error = 0; $eventId = array_keys($_POST['update_event']); $eventId = $eventId[0]; @@ -213,19 +215,21 @@ elseif($action == 'event' && isset($_POST['update_event'])) $eventValue = $optValue; $eventValue = $eventValue[$eventId]; - if(!empty($eventName)) { + if (!empty($eventName)) + { $eventName = trim($eventName); } else { - $error = true; + $error++; } - if(!empty($eventValue)) { + if (!empty($eventValue)) + { $eventValue = price2num($eventValue,2); } else { - $error = true; + $error++; } - if(!$error) + if (!$error) { // Mise à jour des congés de l'utilisateur $update = $cp->updateEventCP($eventId,$eventName,$eventValue); diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 1cf37e77d6f..f167422f503 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -82,7 +82,7 @@ if ($action == 'update' && isset($_POST['update_cp'])) $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. dol_syslog('define_holiday update lastUpdate entry sql='.$sql); - $result = $db->query($sql); + $result = $db->query($sql); $mesg='
'.$langs->trans('UpdateConfCPOK').'
'; @@ -91,21 +91,24 @@ if ($action == 'update' && isset($_POST['update_cp'])) } elseif($action == 'add_event') { - $error = false; + $error = 0; if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) { $event = $_POST['list_event']; - } else { $error = true; + } else { $error++; } if(!empty($_POST['userCP']) && $_POST['userCP'] > 0) { $userCP = $_POST['userCP']; - } else { $error = true; + } else { $erro++; } - if($error) { + if ($error) + { $message = '
'.$langs->trans('ErrorAddEventToUserCP').'
'; - } else { + } + else + { $nb_holiday = $holiday->getCPforUser($userCP); $add_holiday = $holiday->getValueEventCp($event); $new_holiday = $nb_holiday + $add_holiday; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5eaf183428d..a2d2ee36d9c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1043,14 +1043,14 @@ class Product extends CommonObject /** - * Lit le prix pratique par un fournisseur - * On renseigne le couple prodfournprice/qty ou le triplet qty/product_id/fourn_ref + * Read price used by a provider + * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref * * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price * @param double $qty Quantity asked * @param int $product_id Filter on a particular product id * @param string $fourn_ref Filter on a supplier ref - * @return int <-1 if KO, -1 if qty not enough, 0 si ok mais rien trouve, id_product si ok et trouve + * @return int <-1 if KO, -1 if qty not enough, 0 si ok mais rien trouve, id_product si ok et trouve. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) */ function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0) { @@ -1081,7 +1081,7 @@ class Product extends CommonObject { // We do same select again but searching with qty, ref and id product $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; - $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.tva_tx"; + $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'"; $sql.= " AND pfp.fk_product = ".$product_id; @@ -1096,9 +1096,11 @@ class Product extends CommonObject $obj = $this->db->fetch_object($resql); if ($obj && $obj->quantity > 0) // If found { - $this->buyprice = $obj->price; // \deprecated + $this->buyprice = $obj->price; // deprecated + $this->fourn_qty = $obj->quantity; // min quantity for price $this->fourn_pu = $obj->price / $obj->quantity; // Prix unitaire du produit pour le fournisseur $fourn_id - $this->ref_fourn = $obj->ref_fourn; // Ref supplier + $this->ref_fourn = $obj->ref_supplier; // deprecated + $this->ref_supplier = $obj->ref_supplier; // Ref supplier $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier $result=$obj->fk_product; return $result; diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 2eccb9095a5..40e99a2d2ee 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -445,11 +445,15 @@ else if (! empty($conf->service->enabled) && $type != 0) { print '
'; - if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([0-9]+)m/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([0-9]+)w/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); - elseif (preg_match('/([0-9]+)d/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); - else print $objp->duration; + if (preg_match('/([0-9]+)[a-z]/i',$objp->duration)) + { + if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); + elseif (preg_match('/([0-9]+)m/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); + elseif (preg_match('/([0-9]+)w/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); + elseif (preg_match('/([0-9]+)d/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); + //elseif (preg_match('/([0-9]+)h/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); + else print $objp->duration; + } print '
'; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index a1bec8fe86c..63b789a4597 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2270,6 +2270,8 @@ li.cal_event { border: none; list-style-type: none; } /* Ajax - Liste deroulante de l'autocompletion */ /* ============================================================================== */ +.ui-widget-content { border: solid 1px rgba(0,0,0,.3); background: #fff; } + .ui-autocomplete-loading { background: white url() right center no-repeat; } .ui-autocomplete { position:absolute; @@ -2483,7 +2485,7 @@ A.none, A.none:active, A.none:visited, A.none:hover { { line-height: 1em !important; } -.ui-autocomplete-input { margin: 0; } +.ui-autocomplete-input { margin: 0; padding: 2px; } /* ============================================================================== */ diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 11035d148d5..2178ad6fb5a 100755 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -186,6 +186,9 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase $input='xxx
'; $after=dol_textishtml($input); $this->assertTrue($after); + $input='

abc

'; + $after=dol_textishtml($input); + $this->assertTrue($after); // False $input='xxx < br>'; @@ -594,16 +597,16 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase public function testVerifCond() { $verifcond=verifCond('1==1'); - $this->assertTrue($verifcond); + $this->assertTrue($verifcond,'Test a true comparison'); $verifcond=verifCond('1==2'); - $this->assertFalse($verifcond); + $this->assertFalse($verifcond,'Test a false comparison'); $verifcond=verifCond('$conf->facture->enabled'); - $this->assertTrue($verifcond); + $this->assertTrue($verifcond,'Test that conf property of a module report true when enabled'); $verifcond=verifCond('$conf->moduledummy->enabled'); - $this->assertFalse($verifcond); + $this->assertFalse($verifcond,'Test that conf property of a module report false when disabled'); $verifcond=verifCond(''); $this->assertTrue($verifcond);