diff --git a/ChangeLog b/ChangeLog index c1b6443fa18..fac343cbfc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -119,6 +119,7 @@ Fix: [ bug #1043 ] Bad interventions ref numbering Fix: Mailing module : if an email is already in destinaires list all other email from selector was not inserted Fix: Localtaxes balance not showing Fix: Intervention box links to contracts id +Fix: Compatiblity with multicompany module ***** ChangeLog for 3.4 compared to 3.3.* ***** For users: diff --git a/doc/images/dolibarr_screenshot1_640x400.png b/doc/images/dolibarr_screenshot1_640x400.png new file mode 100644 index 00000000000..9ed384263ad Binary files /dev/null and b/doc/images/dolibarr_screenshot1_640x400.png differ diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index e60a76bd936..ab964100c04 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -107,8 +107,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg '%MONTH%'=>$month, '%DAY%'=>$day, '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, - '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/", - '%SOCIETE%'=>$objp->company + '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" ); complete_substitutions_array($substitutionarray, $langs); @@ -204,7 +203,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg dol_print_error($db); } - if (! $mesg) + if (! $mesg) { $db->close(); exit; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 268681a8b46..fddbefa8d5f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2013 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 @@ -610,8 +611,8 @@ class Categorie $sql = "SELECT fk_parent as id_parent, rowid as id_son"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; $sql.= " WHERE fk_parent != 0"; - $sql.= " AND entity = ".$conf->entity; - + $sql.= " AND entity IN (".getEntity('category',1).")"; + dol_syslog(get_class($this)."::load_motherof sql=".$sql); $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 05f60f9d8eb..edac096c8f0 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1521,6 +1521,10 @@ if ($action == 'create' && $user->rights->commande->creer) $objectsrc->fetch($originid); if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines(); $objectsrc->fetch_thirdparty(); + + //Replicate extrafields + $objectsrc->fetch_optionals($originid); + $object->array_options=$objectsrc->array_options; $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); $ref_client = (!empty($objectsrc->ref_client)?$objectsrc->ref_client:''); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index ba1e48bb894..7e82e4d38d3 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2022,6 +2022,10 @@ if ($action == 'create') $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; + + //Replicate extrafields + $objectsrc->fetch_optionals($originid); + $object->array_options=$objectsrc->array_options; } } else @@ -2174,7 +2178,7 @@ if ($action == 'create') print ''."\n"; } - if ((empty($origin)) || (($origin=='propal') && (!empty($originid)))) + if ((empty($origin)) || ((($origin=='propal') || ($origin=='commande')) && (!empty($originid)))) { // Deposit print ''; @@ -2182,7 +2186,7 @@ if ($action == 'create') print ''; $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); print ''; - if (($origin=='propal') ) { + if (($origin=='propal') || ($origin=='commande')) { print ''; print '
'.$desc.''.$langs->trans('Value').':'; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index ac603837240..aa626fdb893 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -71,7 +71,7 @@ class DolGraph var $showlegend=1; var $showpointvalue=1; var $showpercent=0; - + var $graph; // Objet Graph (Artichow, Phplot...) var $error; @@ -244,17 +244,17 @@ class DolGraph $this->data = $data; } - /** - * Set data - * - * @param array $datacolor Data color array(array(R,G,B),array(R,G,B)...) - * @return void - */ - function SetDataColor($datacolor) - { - $this->datacolor = $datacolor; + /** + * Set data + * + * @param array $datacolor Data color array(array(R,G,B),array(R,G,B)...) + * @return void + */ + function SetDataColor($datacolor) + { + $this->datacolor = $datacolor; } - + /** * Set type * @@ -395,7 +395,7 @@ class DolGraph /** * Show legend or not - * + * * @param int $showlegend 1=Show legend (default), 0=Hide legend * @return void */ @@ -406,7 +406,7 @@ class DolGraph /** * Show pointvalue or not - * + * * @param int $showpointvalue 1=Show value for each point, as tooltip or inline (default), 0=Hide value * @return void */ @@ -414,10 +414,10 @@ class DolGraph { $this->showpointvalue=$showpointvalue; } - + /** * Show percent or not - * + * * @param int $showpercent 1=Show percent for each point, as tooltip or inline, 0=Hide percent (default) * @return void */ @@ -425,9 +425,9 @@ class DolGraph { $this->showpercent=$showpercent; } - - - + + + /** * Define background color of complete image * @@ -590,12 +590,18 @@ class DolGraph /** * Build a graph onto disk using correct library * - * @param string $file Image file name to use if we save onto disk + * @param string $file Image file name to use to save onto disk (also used as javascript unique id) * @param string $fileurl Url path to show image if saved onto disk * @return void */ function draw($file,$fileurl='') { + if (empty($file)) + { + $this->error="Call to draw method was made with empty value for parameter file."; + dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR); + return -2; + } if (! is_array($this->data) || count($this->data) < 1) { $this->error="Call to draw method was made but SetData was not called or called with an empty dataset for parameters"; @@ -796,8 +802,8 @@ class DolGraph * $this->mode = 'depth' ??? * $this->bgcolorgrid * $this->datacolor - * - * @param string $file Image file name to use if we save onto disk + * + * @param string $file Image file name to use to save onto disk (also used as javascript unique id) * @param string $fileurl Url path to show image if saved onto disk * @return void */ @@ -807,6 +813,12 @@ class DolGraph dol_syslog(get_class($this)."::draw_jflot this->type=".join(',',$this->type)); + if (empty($this->width) && empty($this->height)) + { + print 'Error width or height not set'; + return; + } + $legends=array(); $nblot=count($this->data[0])-1; // -1 to remove legend if ($nblot < 0) dol_print_error('Bad value for property ->data. Must be set by mydolgraph->SetData before callinf mydolgrapgh->draw'); @@ -823,7 +835,7 @@ class DolGraph // Fill array $values $x=0; - foreach($this->data as $valarray) // Loop on each x + foreach($this->data as $valarray) // Loop on each x { $legends[$x] = $valarray[0]; $values[$x] = (is_numeric($valarray[$i+1]) ? $valarray[$i+1] : null); @@ -839,12 +851,12 @@ class DolGraph { foreach($values as $x => $y) { if (isset($y)) $serie[$i].='d'.$i.'.push(['.$x.', '.$y.']);'."\n"; } } - + unset($values); $i++; } $tag=dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file),'_',array('-','.')))); - + $this->_stringtoshow =''."\n"; if (! empty($this->title)) $this->_stringtoshow.='
'.$this->title.'
'; $this->_stringtoshow.='
'."\n"; @@ -868,7 +880,7 @@ class DolGraph $showlegend=$this->showlegend; $showpointvalue=$this->showpointvalue; $showpercent=$this->showpercent; - + $this->_stringtoshow.= ' function plotWithOptions_'.$tag.'() { $.plot($("#placeholder_'.$tag.'"), d0, @@ -933,16 +945,16 @@ class DolGraph opacity: 0.80 }).appendTo("body").fadeIn(20); } - + var previousPoint = null; $("#placeholder_'.$tag.'").bind("plothover", function (event, pos, item) { $("#x").text(pos.x.toFixed(2)); $("#y").text(pos.y.toFixed(2)); - + if (item) { if (previousPoint != item.dataIndex) { previousPoint = item.dataIndex; - + $("#tooltip").remove(); /* console.log(item); */ var x = item.datapoint[0].toFixed(2); @@ -962,9 +974,9 @@ class DolGraph } }); '; - + $this->_stringtoshow.='var stack = null, steps = false;'."\n"; - + $this->_stringtoshow.='function plotWithOptions_'.$tag.'() {'."\n"; $this->_stringtoshow.='$.plot($("#placeholder_'.$tag.'"), [ '."\n"; $i=$firstlot; @@ -979,7 +991,7 @@ class DolGraph $i++; } $this->_stringtoshow.="\n".' ], { series: { stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6 } }'."\n"; - + // Xaxis $this->_stringtoshow.=', xaxis: { ticks: ['."\n"; $x=0; @@ -990,10 +1002,10 @@ class DolGraph $x++; } $this->_stringtoshow.='] }'."\n"; - + // Yaxis $this->_stringtoshow.=', yaxis: { min: '.$this->MinValue.', max: '.($this->MaxValue).' }'."\n"; - + // Background color $color1=sprintf("%02x%02x%02x",$this->bgcolorgrid[0],$this->bgcolorgrid[0],$this->bgcolorgrid[2]); $color2=sprintf("%02x%02x%02x",$this->bgcolorgrid[0],$this->bgcolorgrid[1],$this->bgcolorgrid[2]); @@ -1001,7 +1013,7 @@ class DolGraph //$this->_stringtoshow.=', shadowSize: 20'."\n"; TODO Uncommet this $this->_stringtoshow.='});'."\n"; $this->_stringtoshow.='}'."\n"; - + } $this->_stringtoshow.='plotWithOptions_'.$tag.'();'."\n"; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 051c9950fd2..469f6e02fbc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -683,9 +683,9 @@ class ExtraFields } elseif ($type == 'sellist') { - $out='
'; print ''; llxFooter(); $db->close(); + +function activitytrim($product_type) +{ + global $conf,$langs,$db; + + // on affiche les 3 dernières années + $yearofbegindate=date('Y',dol_time_plus_duree(time(), -3, "y")); + + // ventilation par trimestre + $sql = "SELECT DATE_FORMAT(p.datep,'%Y') as annee, DATE_FORMAT(p.datep,'%m') as mois, sum(fd.total_ht) as Mnttot"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; + $sql.= " , ".MAIN_DB_PREFIX."paiement as p,".MAIN_DB_PREFIX."paiement_facture as pf"; + $sql.= " WHERE f.fk_soc = s.rowid"; + $sql.= " AND f.rowid = fd.fk_facture"; + $sql.= " AND pf.fk_facture = f.rowid"; + $sql.= " AND pf.fk_paiement= p.rowid"; + $sql.= " AND fd.product_type=".$product_type; + $sql.= " AND s.entity = ".$conf->entity; + $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($yearofbegindate),1)."'"; + $sql.= " GROUP BY annee, mois "; + $sql.= " ORDER BY annee, mois "; + + $result = $db->query($sql); + if ($result) + { + $tmpyear=$beginyear; + $trim1=0; + $trim2=0; + $trim3=0; + $trim4=0; + $lgn = 0; + $num = $db->num_rows($result); + + if ($num > 0 ) + { + print '
'; + print ''; + + if ($product_type==0) + print ''; + else + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + $i = 0; + + while ($i < $num) + { + $objp = $db->fetch_object($result); + if ($tmpyear != $objp->annee) + { + if ($trim1+$trim2+$trim3+$trim4 > 0) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $lgn++; + } + // on passe à l'année suivante + $tmpyear = $objp->annee; + $trim1=0; + $trim2=0; + $trim3=0; + $trim4=0; + } + + if ($objp->mois == "01" || $objp->mois == "02" || $objp->mois == "03") + $trim1 += $objp->Mnttot; + + if ($objp->mois == "04" || $objp->mois == "05" || $objp->mois == "06") + $trim2 += $objp->Mnttot; + + if ($objp->mois == "07" || $objp->mois == "08" || $objp->mois == "09") + $trim3 += $objp->Mnttot; + + if ($objp->mois == "10" || $objp->mois == "11" || $objp->mois == "12") + $trim4 += $objp->Mnttot; + + $i++; + } + if ($trim1+$trim2+$trim3+$trim4 > 0) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + if ($num > 0 ) + print '
'.$langs->trans("ProductSellByQuarterHT").'
'.$langs->trans("ServiceSellByQuarterHT").''.$langs->trans("Quarter1").''.$langs->trans("Quarter2").''.$langs->trans("Quarter3").''.$langs->trans("Quarter4").''.$langs->trans("Total").'
'.$tmpyear.''.price($trim1).''.price($trim2).''.price($trim3).''.price($trim4).''.price($trim1+$trim2+$trim3+$trim4).'
'.$tmpyear.''.price($trim1).''.price($trim2).''.price($trim3).''.price($trim4).''.price($trim1+$trim2+$trim3+$trim4).'
'; + } +} + ?> diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index bd73628eec3..98f8e79fd1c 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -211,6 +211,22 @@ if ($action == 'setprofid') } } +//Activate Set ref in list +if ($action=="setaddrefinlist") { + $setaddrefinlist = GETPOST('value','int'); + $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist,'yesno',0,'',$conf->entity); + if (! $res > 0) $error++; + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } +} + + //Activate ProfId mandatory if ($action == 'setprofidmandatory') { @@ -717,6 +733,23 @@ else print ''; print ''; +$var=!$var; +print ""; +print ''.$langs->trans("AddRefInList").''; +if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) +{ + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); + print ''; +} +else +{ + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; +} +print ''; + $var=!$var; print '
'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9127adc3a8f..bd1fae497f2 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1433,6 +1433,16 @@ class Societe extends CommonObject $name=$this->name?$this->name:$this->nom; + if ($conf->global->SOCIETE_ADD_REF_IN_LIST) { + if (($this->client) && (! empty ( $this->code_client ))) { + $code = $this->code_client . ' - '; + } + if (($this->fournisseur) && (! empty ( $this->code_fournisseur ))) { + $code .= $this->code_fournisseur . ' - '; + } + $name =$code.' '.$name; + } + $result=''; $lien=$lienfin=''; @@ -1571,18 +1581,18 @@ class Societe extends CommonObject } /** - * Return list of contacts emails or mobile existing for third party + * Return list of contacts emails or mobile existing for third party * - * @param string $mode 'email' or 'mobile' - * @return array Array of contacts emails or mobile + * @param string $mode 'email' or 'mobile' + * @param int $hidedisabled 1=Hide contact if disabled + * @return array Array of contacts emails or mobile */ - function contact_property_array($mode='email') + function contact_property_array($mode='email', $hidedisabled=0) { $contact_property = array(); - - $sql = "SELECT rowid, email, statut, phone_mobile, lastname, firstname"; + $sql = "SELECT rowid, email, statut, phone_mobile, lastname, poste, firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; $sql.= " WHERE fk_soc = '".$this->id."'"; @@ -1599,12 +1609,18 @@ class Societe extends CommonObject if ($mode == 'email') $property=$obj->email; else if ($mode == 'mobile') $property=$obj->phone_mobile; - - if ($obj->statut == 1) + // Show all contact. If hidedisabled is 1, showonly contacts with status = 1 + if ($obj->statut == 1 || empty($hidedisabled)) { - $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname))." <".$property.">"; - - } + if (!empty($obj->poste)) + { + $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname))."(".$obj->poste.")"." <".$property.">"; + } + else + { + $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname))." <".$property.">"; + } + } $i++; } }