diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index e0623788963..709d07c0832 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -162,21 +162,13 @@ if ($type == 'directory') // Auto area for suppliers invoices else if ($module == 'invoice') $upload_dir = $conf->facture->dir_output; // Auto area for suppliers invoices - else if ($module == 'invoice_supplier') - { - $relativepath='facture'; - $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath; - } + else if ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; // Auto area for customers orders else if ($module == 'propal') $upload_dir = $conf->propal->dir_output; // Auto area for customers orders else if ($module == 'order') $upload_dir = $conf->commande->dir_output; // Auto area for suppliers orders - else if ($module == 'order_supplier') - { - $relativepath='commande'; - $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath; - } + else if ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; // Auto area for suppliers invoices else if ($module == 'contract') $upload_dir = $conf->contrat->dir_output; // Auto area for products @@ -198,6 +190,8 @@ if ($type == 'directory') $param.='&module='.$module; $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound"))); + if ($module == 'company') $excludefiles[]='^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + $filearray=dol_dir_list($upload_dir,"files",1,'', $excludefiles, $sortfield, $sorting,1); $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname,$url); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b87b3d28ea8..3c902495118 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1486,7 +1486,7 @@ abstract class CommonObject $fieldname = 'multicurrency_code'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = "'.$this->db->escape($code).'"'; + $sql .= ' SET '.$fieldname." = '".$this->db->escape($code)."'"; $sql .= ' WHERE rowid='.$this->id; if ($this->db->query($sql)) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index a7a7540ca18..77c24ff4109 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -488,8 +488,8 @@ class Conf // By default, we propagate contacts if (! isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN='*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented) - // By default, we use the zip town autofill - if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=1; + // By default, we do not use the zip town table but the table of third parties + if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=0; // By default, we open card if one found if (! isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE=1; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 6d4d5d38b55..a5ccb33f084 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1002,6 +1002,7 @@ class FormFile print ''; print ''; } + print '
'; print ''."\n"; @@ -1106,8 +1107,6 @@ class FormFile && $file['name'] != '..' && ! preg_match('/\.meta$/i',$file['name'])) { - - if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid']; $editline=0; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4fea390607a..4629324dc84 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4159,7 +4159,7 @@ function getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1) * @param Societe $buyer Company object * @param Societe $seller Company object * @param int $firstparamisid 1 if first param is id into table (use this if you can) - * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @return array array(localtax_type1(1-6/0 if not found), rate localtax1, localtax_type1, rate localtax2, accountancycodecust, accountancycodesupp) * @see getTaxesFromId */ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0) @@ -4197,22 +4197,22 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi { if (! isOnlyOneLocalTax(1)) { - return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } else { - return array($obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell, $obj->accountancy_code_buy); } } elseif ($local == 2) { if (! isOnlyOneLocalTax(2)) { - return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller),$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller),$obj->accountancy_code_sell, $obj->accountancy_code_buy); } else { - return array($obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell, $obj->accountancy_code_buy); } } else @@ -4221,22 +4221,22 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi { if(! isOnlyOneLocalTax(2)) { - return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller),$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell,$obj->accountancy_code_buy); } else { - return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy); } } else { if(! isOnlyOneLocalTax(2)) { - return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type,get_localtax($vatrate, 2, $buyer, $seller) ,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } else { - return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy); } } } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index d02f820d0d5..1be45a27f7d 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -52,7 +52,7 @@ if (in_array($object->element,array('propal', 'supplier_proposal','facture','fac ?> -lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { ?> @@ -120,10 +120,10 @@ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay=2; ?> - + multicurrency->enabled)) { $colspan++;?> - +
- @@ -278,13 +278,13 @@ else { "> "> "> @@ -738,9 +738,10 @@ function setforfree() { function setforpredef() { console.log("Call setforpredef. We hide some fields"); jQuery("#select_type").val(-1); + jQuery("#prod_entry_mode_free").prop('checked',false).change(); jQuery("#prod_entry_mode_predef").prop('checked',true).change(); - jQuery("#price_ht").hide(); + jQuery("#price_ht").val('').hide(); jQuery("#multicurrency_price_ht").hide(); jQuery("#price_ttc").hide(); // May no exists jQuery("#tva_tx").hide(); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 1a36f68a81a..711bd5e767d 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -49,7 +49,7 @@ class Expedition extends CommonObject public $table_element_line="expeditiondet"; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'sending'; - + var $socid; var $ref_customer; var $ref_int; @@ -399,7 +399,7 @@ class Expedition extends CommonObject { $error++; } - + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $expeditionline = new ExpeditionLigne($this->db); @@ -918,7 +918,7 @@ class Expedition extends CommonObject $this->error='ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH'; return -4; } - + // extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used $line->array_options = $array_options; @@ -1319,7 +1319,8 @@ class Expedition extends CommonObject $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type"; $sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; - $sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; + $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; + $sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc"; $sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; @@ -1392,8 +1393,10 @@ class Expedition extends CommonObject $line->pa_ht = $obj->pa_ht; + $localtax_array=array(0=>$obj->localtax1_type, 1=>$obj->localtax1_tx, 2=>$obj->localtax2_type, 3=>$obj->localtax2_tx); + // For invoicing - $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc); // We force type to 0 + $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0 $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) $line->qty = $line->qty_shipped; $line->total_ht = $tabprice[0]; @@ -1401,6 +1404,7 @@ class Expedition extends CommonObject $line->total_localtax2 = $tabprice[10]; $line->total_ttc = $tabprice[2]; $line->total_tva = $tabprice[1]; + $line->vat_src_code = $obj->vat_src_code; $line->tva_tx = $obj->tva_tx; $line->localtax1_tx = $obj->localtax1_tx; $line->localtax2_tx = $obj->localtax2_tx; @@ -1414,6 +1418,14 @@ class Expedition extends CommonObject $this->total_localtax1+= $tabprice[9]; $this->total_localtax2+= $tabprice[10]; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_subprice = $obj->multicurrency_subprice; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + if ($originline != $obj->fk_origin_line) { $line->detail_batch = array(); @@ -1482,7 +1494,7 @@ class Expedition extends CommonObject $label = '' . $langs->trans("ShowSending") . ''; $label .= '
' . $langs->trans('Ref') . ': '.$this->ref; $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); - + $url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id; if ($short) return $url; @@ -1498,7 +1510,7 @@ class Expedition extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; diff --git a/htdocs/projet/ganttchart.inc.php b/htdocs/projet/ganttchart.inc.php index 4e1b53d3f24..2600fbd02fc 100644 --- a/htdocs/projet/ganttchart.inc.php +++ b/htdocs/projet/ganttchart.inc.php @@ -141,7 +141,7 @@ else function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_id=null) { global $dateformatinput2; - + $start_date = $task["task_start_date"]; $end_date = $task["task_end_date"]; if (!$end_date) $end_date = $start_date; @@ -206,7 +206,7 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_ $s = "\n// Add taks id=".$task["task_id"]." level = ".$level."\n"; // $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js($name)."','".$start_date."', '".$end_date."', '".$task['task_color']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]>0?1:0).", '".$parent."', 1, '".($depend?$depend:"")."', '".$note."'));"; // For JSGanttImproved - $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js(trim($name))."','".$start_date."', '".$end_date."', '".$task['task_css']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]).", '".$parent."', 1, '".($depend?$depend:$parent."SS")."', '".($percent >= 0 ? $percent.'%' : '0%')."','".$task['note']."'));"; + $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js(trim($name))."','".$start_date."', '".$end_date."', '".$task['task_css']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]).", '".$parent."', 1, '".($depend?$depend:$parent."SS")."', '".($percent >= 0 ? $percent.'%' : '0%')."','".dol_escape_js($task['note'])."'));"; echo $s; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 1352e8c154c..b4d93feb511 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1372,7 +1372,7 @@ if ($action == 'create') $morehtmlref.='
'; $morehtmlref.=''; $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=''; $morehtmlref.='
'; } else {