diff --git a/COPYRIGHT b/COPYRIGHT index 519910ea1b1..896bb571bbe 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -42,7 +42,7 @@ jQuery jNotify 1.1.00 Apache Software License 2.0 Yes jQuery jPicker 1.1.6 GPL and MIT License Yes JS library for color picker with not defined list of colors jQuery jqueryFileTree 1.0.1 GPL and MIT License Yes JS library for color picker with not defined list of colors jQuery jquerytreeview 1.4.1 MIT License Yes JS library for color picker with not defined list of colors -jQuery Layout 1.3.0rc30.74 GPL and MIT License Yes JS library plugin Layout (RC-29.15) +jQuery Layout 1.4.3 GPL and MIT License Yes JS library plugin Layout (RC-29.15) jQuery Mobile 1.3.0 GPL and MIT License Yes JS library for smartphone (not used) jQuery TableDnD 0.6 GPL and MIT License Yes JS library plugin TableDnD (to reorder table rows) jQuery Timepicker 1.1.0 GPL and MIT License Yes JS library Timepicker addon for Datepicker @@ -62,6 +62,7 @@ Copyright (C) 2015 - Marcos García - Alexandre Spangaro - Frederic France +- Regis Houssin Copyright (C) 2014 - Laurent Destailleur diff --git a/dev/examples/get_contracts.php b/dev/examples/get_contracts.php index ddfeccb5677..d1be3d9d7bf 100755 --- a/dev/examples/get_contracts.php +++ b/dev/examples/get_contracts.php @@ -73,7 +73,7 @@ $obj->socid=$argv[1]; $listofcontractsforcompany=$obj->getListOfContracts('all'); -print_r($listofcontractsforcompany); +print $listofcontractsforcompany; // -------------------- END OF YOUR CODE -------------------- diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index ca10cf49ef0..e83b9e2debf 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -117,6 +117,14 @@ if ($resql) { $property[$i]['ischar']=false; } + if (preg_match('/int/i',$property[$i]['type'])) + { + $property[$i]['isint']=true; + } + else + { + $property[$i]['isint']=false; + } } } else @@ -135,7 +143,7 @@ foreach($property as $key => $prop) $i++; if ($prop['field'] != 'rowid') { - $varpropselect.="\t\t\$sql.= \" "; + $varpropselect.="\t\t\$sql .= \" "; $varpropselect.="t.".$prop['field']; if ($i < count($property)) $varpropselect.=","; $varpropselect.="\";"; @@ -173,8 +181,8 @@ $targetcontent=$sourcecontent; // Substitute class name $targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent); -$targetcontent=preg_replace('/\$element=\'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent); -$targetcontent=preg_replace('/\$table_element=\'skeleton\'/', '\$table_element=\''.$tablenoprefix.'\'', $targetcontent); +$targetcontent=preg_replace('/\$element = \'skeleton\'/', '\$element = \''.$classmin.'\'', $targetcontent); +$targetcontent=preg_replace('/\$table_element = \'skeleton\'/', '\$table_element = \''.$tablenoprefix.'\'', $targetcontent); $targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent); // Substitute comments @@ -192,15 +200,18 @@ foreach($property as $key => $prop) { if ($prop['field'] != 'rowid' && $prop['field'] != 'id') { - $varprop.="\tvar \$".$prop['field']; - if ($prop['istime']) $varprop.="=''"; + $varprop.="\tpublic \$".$prop['field']; + if ($prop['istime']) $varprop.=" = ''"; $varprop.=";"; if ($prop['comment']) $varprop.="\t// ".$prop['extra']; $varprop.="\n"; } } -$targetcontent=preg_replace('/var \$prop1;/', $varprop, $targetcontent); -$targetcontent=preg_replace('/var \$prop2;/', '', $targetcontent); +$targetcontent=preg_replace('/public \$prop1;/', $varprop, $targetcontent); +$targetcontent=preg_replace('/public \$prop2;/', '', $targetcontent); + +$targetcontent=preg_replace('/\*((\s|\n|\r|\t)*)\@var mixed Sample property 1((\s|\n|\r|\t)*)/', '', $targetcontent); +$targetcontent=preg_replace('/\*((\s|\n|\r|\t)*)\@var mixed Sample property 2((\s|\n|\r|\t)*)/', '', $targetcontent); // Substitute clean parameters $varprop="\n"; @@ -209,12 +220,12 @@ foreach($property as $key => $prop) { if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) { - $varprop.="\t\tif (isset(\$this->".$prop['field'].")) \$this->".$prop['field']."=trim(\$this->".$prop['field'].");"; + $varprop.="\t\tif (isset(\$this->".$prop['field'].")) {\n\t\t\t \$this->".$prop['field']." = trim(\$this->".$prop['field'].");\n\t\t}"; $varprop.="\n"; } } -$targetcontent=preg_replace('/if \(isset\(\$this->prop1\)\) \$this->prop1=trim\(\$this->prop1\);/', $varprop, $targetcontent); -$targetcontent=preg_replace('/if \(isset\(\$this->prop2\)\) \$this->prop2=trim\(\$this->prop2\);/', '', $targetcontent); +$targetcontent=preg_replace('/if \(isset\(\$this->prop1\)\) {((\n|\r|\t)*)\$this->prop1 = trim\(\$this->prop1\);((\n|\r|\t)*)}/', $varprop, $targetcontent); +$targetcontent=preg_replace('/if \(isset\(\$this->prop2\)\) {((\n|\r|\t)*)\$this->prop2 = trim\(\$this->prop2\);((\n|\r|\t)*)}/', '', $targetcontent); // Substitute insert into parameters $varprop="\n"; @@ -229,120 +240,142 @@ foreach($property as $key => $prop) if ($addfield) { - $varprop.="\t\t\$sql.= \"".$prop['field']; + $varprop.="\t\t\$sql.= '".$prop['field']; if ($i < count($property)) $varprop.=","; - $varprop.="\";"; + $varprop.="';"; $varprop.="\n"; } } -$targetcontent=preg_replace('/\$sql\.= " field1,";/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\$sql\.= " field2";/', '', $targetcontent); +$targetcontent=preg_replace('/\$sql \.= \' field1,\';/', $varprop, $targetcontent); +$targetcontent=preg_replace('/\$sql \.= \' field2\';/', '', $targetcontent); // Substitute insert values parameters $varprop="\n"; $cleanparam=''; $i=0; + +//Count nb field to output to manage commat at end SQL instruction +$no_output_field=0; foreach($property as $key => $prop) { - $i++; + if ($prop['field'] == 'tms') $no_output_field++; // This is a field of type timestamp edited automatically + if ($prop['extra'] == 'auto_increment') $no_output_field++; +} + +foreach($property as $key => $prop) +{ + $addfield=1; if ($prop['field'] == 'tms') $addfield=0; // This is a field of type timestamp edited automatically if ($prop['extra'] == 'auto_increment') $addfield=0; - + if ($addfield) { - $varprop.="\t\t\$sql.= \" "; + $i++; + + $varprop.="\t\t\$sql .= ' "; if ($prop['field']=='datec') { - $varprop.='"."\'".$this->db->idate(dol_now())."\'"."'; - if ($i < count($property)) $varprop.=","; - $varprop.='";'; + $varprop.='\'."\'".$this->db->idate(dol_now())."\'"'; } elseif ($prop['istime']) { - $varprop.='".(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].')==0?\'NULL\':"\'".$this->db->idate('; + $varprop.='\'.(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].')==0?\'NULL\':"\'".$this->db->idate('; $varprop.="\$this->".$prop['field'].""; - $varprop.=')."\'")."'; - if ($i < count($property)) $varprop.=","; - $varprop.='";'; + $varprop.=").\"'\")"; } elseif ($prop['ischar']) { - $varprop.='".(! isset($this->'.$prop['field'].')?\'NULL\':"\'".'; - $varprop.='$this->db->escape($this->'.$prop['field'].')'; - $varprop.='."\'")."'; - if ($i < count($property)) $varprop.=","; - $varprop.='";'; + $varprop.="'.(! isset(\$this->".$prop['field'].")?'NULL':\"'\"."; + $varprop.="\$this->db->escape(\$this->".$prop['field'].")"; + $varprop.=".\"'\")"; } elseif ($prop['field']=='fk_user_mod' || $prop['field']=='fk_user_author') { - $varprop.='".$user->id."'; - if ($i < count($property)) $varprop.=","; - $varprop.='";'; + $varprop.="'.\$user->id"; + } + elseif ($prop['isint']) + { + $varprop.='\'.(! isset($this->'.$prop['field'].')?\'NULL\':'; + $varprop.="\$this->".$prop['field'].""; + $varprop.=')'; } else { - $varprop.='".(! isset($this->'.$prop['field'].')?\'NULL\':"\'".'; + $varprop.=' \'.(! isset($this->'.$prop['field'].')?\'NULL\':"\'".'; $varprop.="\$this->".$prop['field'].""; - $varprop.='."\'")."'; - if ($i < count($property)) $varprop.=","; - $varprop.='";'; + $varprop.='.\').'; + } + if ($i < (count($property)-$no_output_field)) $varprop.=".','"; + $varprop.=';'; $varprop.="\n"; } } -$targetcontent=preg_replace('/\$sql\.= " \'".\$this->prop1\."\',";/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\$sql\.= " \'".\$this->prop2\."\'";/', '', $targetcontent); + +$patern1='/\$sql \.= \' (.*)\' \. \$this->prop1 \. \'(.*),\';/'; +$patern2='/\$sql \.= \' (.*)\' \. \$this->prop2 \. \'(.*)\';/'; +$targetcontent=preg_replace($patern1, $varprop, $targetcontent); +$targetcontent=preg_replace($patern2, '', $targetcontent); // Substitute update values parameters + +//Count nb field to output to manage commat at end SQL instruction +$no_output_field=0; +foreach($property as $key => $prop) +{ + if ($prop['extra'] == 'auto_increment') $no_output_field++; +} + $varprop="\n"; $cleanparam=''; $i=0; foreach($property as $key => $prop) { - $i++; - if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && $prop['field'] != 'datec' && $prop['field'] != 'fk_user_author') + + $addfield=1; + if ($prop['extra'] == 'auto_increment') $addfield=0; + + if ($addfield) { - $varprop.="\t\t\$sql.= \" "; - $varprop.=$prop['field'].'='; + $i++; + + $varprop.="\t\t\$sql .= ' "; + $varprop.=$prop['field'].' = '; if ($prop['field']=='tms') { - $varprop.='".(dol_strlen($this->'.$prop['field'].')!=0 ? "\'".$this->db->idate('; + $varprop.='\'.(dol_strlen($this->'.$prop['field'].') != 0 ? "\'".$this->db->idate('; $varprop.='$this->'.$prop['field']; - $varprop.=')."\'" : "\'".$this->db->idate(dol_now())."\'").'; - $varprop.='"'; + $varprop.=')."\'" : "\'".$this->db->idate(dol_now())."\'")'; } elseif ($prop['istime']) { - // (dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null') - $varprop.='".(dol_strlen($this->'.$prop['field'].')!=0 ? "\'".$this->db->idate('; + $varprop.='\'.(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].') != 0 ? "\'".$this->db->idate('; $varprop.='$this->'.$prop['field']; - $varprop.=')."\'" : \'null\').'; - $varprop.='"'; + $varprop.=')."\'" : \'null\')'; } + elseif ($prop['field']=='fk_user_mod') { - $varprop.='".$user->id."'; + $varprop.="'.\$user->id"; } else { - $varprop.="\"."; - // $sql.= " field1=".(isset($this->field1)?"'".$this->db->escape($this->field1)."'":"null").","; + $varprop.="'."; if ($prop['ischar']) $varprop.='(isset($this->'.$prop['field'].')?"\'".$this->db->escape($this->'.$prop['field'].')."\'":"null")'; - // $sql.= " field1=".(isset($this->field1)?$this->field1:"null").","; + elseif ($prop['isint']) $varprop.='(isset($this->'.$prop['field'].')?$this->'.$prop['field'].':"null")'; else $varprop.='(isset($this->'.$prop['field'].')?$this->'.$prop['field'].':"null")'; - $varprop.=".\""; } - if ($i < count($property)) $varprop.=','; - $varprop.='";'; + if ($i < (count($property)-$no_output_field)) $varprop.=".','"; + $varprop.=';'; $varprop.="\n"; } } -$targetcontent=preg_replace('/\$sql.= " field1=".\(isset\(\$this->field1\)\?"\'".\$this->db->escape\(\$this->field1\)."\'":"null"\).",";/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\$sql.= " field2=".\(isset\(\$this->field2\)\?"\'".\$this->db->escape\(\$this->field2\)."\'":"null"\)."";/', '', $targetcontent); +$targetcontent=preg_replace('/\$sql \.= " field1=".\(isset\(\$this->field1\)\?"\'".\$this->db->escape\(\$this->field1\)."\'":"null"\).",";/', $varprop, $targetcontent); +$targetcontent=preg_replace('/\$sql \.= " field2=".\(isset\(\$this->field2\)\?"\'".\$this->db->escape\(\$this->field2\)."\'":"null"\)."";/', '', $targetcontent); // Substitute fetch/select parameters -$targetcontent=preg_replace('/\$sql\.= " t\.field1,";/', $varpropselect, $targetcontent); -$targetcontent=preg_replace('/\$sql\.= " t\.field2";/', '', $targetcontent); +$targetcontent=preg_replace('/\$sql \.= \' t\.field1,\';/', $varpropselect, $targetcontent); +$targetcontent=preg_replace('/\$sql \.= \' t\.field2\';/', '', $targetcontent); // Substitute select set parameters $varprop="\n"; @@ -384,12 +417,12 @@ foreach($property as $key => $prop) { if ($prop['field'] != 'rowid' && $prop['field'] != 'id') { - $varprop.="\t\t\$this->".$prop['field']."='';"; + $varprop.="\t\t\$this->".$prop['field']." = '';"; $varprop.="\n"; } } -$targetcontent=preg_replace('/\$this->prop1=\'prop1\';/', $varprop, $targetcontent); -$targetcontent=preg_replace('/\$this->prop2=\'prop2\';/', '', $targetcontent); +$targetcontent=preg_replace('/\$this->prop1 = \'prop1\';/', $varprop, $targetcontent); +$targetcontent=preg_replace('/\$this->prop2 = \'prop2\';/', '', $targetcontent); // Build file $fp=fopen($outfile,"w"); @@ -425,8 +458,8 @@ $targetcontent=$sourcecontent; // Substitute class name $targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent); $targetcontent=preg_replace('/skeleton_script\.php/', $classmin.'_script.php', $targetcontent); -$targetcontent=preg_replace('/\$element=\'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent); -$targetcontent=preg_replace('/\$table_element=\'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent); +$targetcontent=preg_replace('/\$element = \'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent); +$targetcontent=preg_replace('/\$table_element = \'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent); $targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent); // Substitute comments @@ -471,8 +504,8 @@ $targetcontent=$sourcecontent; // Substitute class name $targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent); $targetcontent=preg_replace('/skeleton_script\.php/', $classmin.'_script.php', $targetcontent); -$targetcontent=preg_replace('/\$element=\'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent); -$targetcontent=preg_replace('/\$table_element=\'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent); +$targetcontent=preg_replace('/\$element = \'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent); +$targetcontent=preg_replace('/\$table_element = \'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent); $targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent); $targetcontent=preg_replace('/skeleton/', $classname, $targetcontent); @@ -485,8 +518,8 @@ $targetcontent=preg_replace('/Put here some comments/','Initialy built by build_ $targetcontent=preg_replace('/MAIN_DB_PREFIX."mytable/', 'MAIN_DB_PREFIX."'.$tablenoprefix, $targetcontent); // Substitute fetch/select parameters -$targetcontent=preg_replace('/\$sql\.= " t\.field1,";/', $varpropselect, $targetcontent); -$targetcontent=preg_replace('/\$sql\.= " t\.field2";/', '', $targetcontent); +$targetcontent=preg_replace('/\$sql \.= " t\.field1,";/', $varpropselect, $targetcontent); +$targetcontent=preg_replace('/\$sql \.= " t\.field2";/', '', $targetcontent); // Build file $fp=fopen($outfile,"w"); diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index eef777a03ca..72ee07c259d 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -303,16 +303,8 @@ class Skeleton_Class extends CommonObject // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - if (isset($this->field1)) { - $sql .= ' field1=\'' . $this->db->escape($this->field1) . '\','; - } else { - $sql .= ' field1=null' . ','; - } - if (isset($this->field2)) { - $sql .= ' field2=\'' . $this->db->escape($this->field2) . '\''; - } else { - $sql .= ' field2=null'; - } + $sql .= " field1=".(isset($this->field1)?"'".$this->db->escape($this->field1)."'":"null").","; + $sql .= " field2=".(isset($this->field2)?"'".$this->db->escape($this->field2)."'":"null").""; //... $sql .= ' WHERE rowid=' . $this->id; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 52c4a0d1862..22e2cc8f260 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -106,13 +106,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_desc=''; } -//debug move header to top -llxHeader('', $langs->trans("Accounts")); - - //TODO: modify to update all selected product with a sell account if (is_array($changeaccount) && count($changeaccount) > 0 && $action == $langs->trans("Accountancy_code_sell")) { -//print_r ($changeaccount); $error = 0; $db->begin(); @@ -121,8 +116,11 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $action == $langs-> $sql1 .= " SET p.accountancy_code_sell=" . $account_number_sell; $sql1 .= ' WHERE p.rowid IN (' . implode(',', $changeaccount) . ')'; - dol_syslog('accountancy/customer/lines.php::changeaccount product sell sql= ' . $sql1); -print_r ($sql1); + // Debug + // print_r ($sql1); + + dol_syslog('accountancy/customer/lines.php::changeaccount product sell sql= ' . $sql1); + $resql1 = $db->query($sql1); if (! $resql1) { $error ++; @@ -137,7 +135,6 @@ print_r ($sql1); } } - //TODO: modify to update all selected product with a buy account if (is_array($changeaccount) && count($changeaccount) > 0 && $action == $langs->trans("Accountancy_code_buy")) { $error = 0; @@ -147,9 +144,13 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $action == $langs-> $sql1 = "UPDATE " . MAIN_DB_PREFIX . "product as p"; $sql1 .= " SET p.accountancy_code_buy=" . $account_number_buy; $sql1 .= ' WHERE p.rowid IN (' . implode(',', $changeaccount) . ')'; -print_r ($sql1); - dol_syslog('accountancy/customer/lines.php::changeaccount product buy sql= ' . $sql1); - $resql1 = $db->query($sql1); + + // Debug + // print_r ($sql1); + + dol_syslog('accountancy/customer/lines.php::changeaccount product buy sql= ' . $sql1); + + $resql1 = $db->query($sql1); if (! $resql1) { $error ++; setEventMessage($db->lasterror(), 'errors'); @@ -166,12 +167,10 @@ print_r ($sql1); /* * View */ -//DEBUG elarifr -//llxHeader('', $langs->trans("Accounts")); +llxHeader('', $langs->trans("Accounts")); -//For updating account export +// For updating account export print ''."\n"; + print ''."\n"; } // jQuery jnotify if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 5ea2ff538b0..4114005ecdd 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -361,6 +361,11 @@ if (empty($reshook)) $form = new Form($db); +if (! empty($id) || ! empty($ref)) +{ + // fetch updated prices + $object->fetch($id, $ref); +} llxHeader("", "", $langs->trans("CardProduct" . $object->type)); $head = product_prepare_head($object); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2c7d3f25053..a1352dacc61 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1039,13 +1039,13 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; if ($rowid) $sql .= ' WHERE s.rowid = '.$rowid; - if ($ref) $sql .= " WHERE s.nom = '".$this->db->escape($ref)."' AND s.entity IN (".getEntity($this->element, 1).")"; - if ($ref_ext) $sql .= " WHERE s.ref_ext = '".$this->db->escape($ref_ext)."' AND s.entity IN (".getEntity($this->element, 1).")"; - if ($ref_int) $sql .= " WHERE s.ref_int = '".$this->db->escape($ref_int)."' AND s.entity IN (".getEntity($this->element, 1).")"; - if ($idprof1) $sql .= " WHERE s.siren = '".$this->db->escape($idprof1)."' AND s.entity IN (".getEntity($this->element, 1).")"; - if ($idprof2) $sql .= " WHERE s.siret = '".$this->db->escape($idprof2)."' AND s.entity IN (".getEntity($this->element, 1).")"; - if ($idprof3) $sql .= " WHERE s.ape = '".$this->db->escape($idprof3)."' AND s.entity IN (".getEntity($this->element, 1).")"; - if ($idprof4) $sql .= " WHERE s.idprof4 = '".$this->db->escape($idprof4)."' AND s.entity IN (".getEntity($this->element, 1).")"; + else if ($ref) $sql .= " WHERE s.nom = '".$this->db->escape($ref)."' AND s.entity IN (".getEntity($this->element, 1).")"; + else if ($ref_ext) $sql .= " WHERE s.ref_ext = '".$this->db->escape($ref_ext)."' AND s.entity IN (".getEntity($this->element, 1).")"; + else if ($ref_int) $sql .= " WHERE s.ref_int = '".$this->db->escape($ref_int)."' AND s.entity IN (".getEntity($this->element, 1).")"; + else if ($idprof1) $sql .= " WHERE s.siren = '".$this->db->escape($idprof1)."' AND s.entity IN (".getEntity($this->element, 1).")"; + else if ($idprof2) $sql .= " WHERE s.siret = '".$this->db->escape($idprof2)."' AND s.entity IN (".getEntity($this->element, 1).")"; + else if ($idprof3) $sql .= " WHERE s.ape = '".$this->db->escape($idprof3)."' AND s.entity IN (".getEntity($this->element, 1).")"; // TODO This request is used ? Multiple database recording provided !! + else if ($idprof4) $sql .= " WHERE s.idprof4 = '".$this->db->escape($idprof4)."' AND s.entity IN (".getEntity($this->element, 1).")"; $resql=$this->db->query($sql); dol_syslog(get_class($this)."::fetch ".$sql); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 102d275b968..6332aab4794 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2195,7 +2195,8 @@ else } // Multicompany - if (! empty($conf->multicompany->enabled)) + // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! + if (! empty($conf->multicompany->enabled) && is_object($mc)) { if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 3ecff112b73..3de421e4f4f 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2015 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Florian Henry * @@ -239,7 +239,7 @@ if ($action == 'create') print ''; // Multicompany - if (! empty($conf->multicompany->enabled)) + if (! empty($conf->multicompany->enabled) && is_object($mc)) { if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { @@ -326,7 +326,7 @@ else print "\n"; // Multicompany - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { $mc->getInfo($object->entity); print "".''.$langs->trans("Entity").''; @@ -401,7 +401,7 @@ else print $form->select_dolusers('','user',1,$exclude,0,'','',$object->entity); print '   '; // Multicompany - if (! empty($conf->multicompany->enabled)) + if (! empty($conf->multicompany->enabled) && is_object($mc)) { if ($conf->entity == 1 && $conf->multicompany->transverse_mode) { @@ -455,7 +455,7 @@ else print ''; print ''.$useringroup->lastname.''; print ''.$useringroup->firstname.''; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { print ''; if (! empty($useringroup->usergroup_entity)) @@ -513,7 +513,7 @@ else print "\n"; // Multicompany - if (! empty($conf->multicompany->enabled)) + if (! empty($conf->multicompany->enabled) && is_object($mc)) { if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index 1f06fa3a3c2..7496d7bc816 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2011 Herve Prot * * This program is free software; you can redistribute it and/or modify @@ -108,7 +108,7 @@ if ($resql) } print ""; //multicompany - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) + if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) { $mc->getInfo($obj->entity); print ''.$mc->label.''; diff --git a/htdocs/user/home.php b/htdocs/user/home.php index cb700b9701e..ba3b3c15586 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2015 Regis Houssin * * 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 @@ -180,21 +180,18 @@ if ($resql) $entity=$obj->entity; $entitystring=''; // TODO Set of entitystring should be done with a hook - if (is_object($mc)) - { - if (! empty($conf->multicompany->enabled)) - { - if (empty($entity)) - { - $entitystring=$langs->trans("AllEntities"); - } - else - { - $mc->getInfo($entity); - $entitystring=$mc->label; - } - } - } + if (! empty($conf->multicompany->enabled) && is_object($mc)) + { + if (empty($entity)) + { + $entitystring=$langs->trans("AllEntities"); + } + else + { + $mc->getInfo($entity); + $entitystring=$mc->label; + } + } print ($entitystring?' ('.$entitystring.')':''); print ''; @@ -259,7 +256,7 @@ if ($canreadperms) print img_picto($langs->trans("GlobalGroup"),'redstar'); } print ""; - if (! empty($conf->multicompany->enabled)) + if (! empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($obj->entity); print '';