diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 1f0d9be22e6..1badb9e8c1e 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -228,16 +228,16 @@ print ''; print ''; print ''; // Company - print ''; // User - print ''; // Year - print ''; + // Number of filtered fields + if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) + { + print ''; + $list=''; + foreach($array_filtered as $code=>$value) + { + $list.=($list?', ':''); + $list.="[".$langs->trans($objexport->array_export_fields[0][$code])."]='".$array_filtervalue[$code]."'"; + } + print ''; + } + print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; + print '
'.$langs->trans("ThirdParty").''; $filter='s.client in (1,2,3)'; print $form->select_company($socid,'socid',$filter,1); print '
'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").''; + print '
'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").''; print $form->select_users($userid,'userid',1); print '
'.$langs->trans("Year").''; + print '
'.$langs->trans("Year").''; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; arsort($arrayyears); print $form->selectarray('year',$arrayyears,$year,0); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5306e8866be..fe3c9bfd424 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1521,7 +1521,22 @@ class Commande extends CommonOrder $nb=0; foreach($this->lines as $line) { - if ($line->fk_product_type == 0) $nb++; + if ($line->product_type == 0) $nb++; + } + return $nb; + } + + /** + * Return number of line with type service. + * + * @return int <0 if KO, Nbr of service lines if OK + */ + function getNbOfServicesLines() + { + $nb=0; + foreach($this->lines as $line) + { + if ($line->product_type == 1) $nb++; } return $nb; } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 641fcbce1ae..9cfc131f979 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1382,8 +1382,8 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines(); $objectsrc->fetch_thirdparty(); - $projectid = (!empty($objectsrc->fk_project)?$object->fk_project:''); - $ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); + $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + $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)); diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index fd97ae70f4a..2d6c906fded 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -249,17 +249,17 @@ print ''; print ''; print ''; // Company - print ''; // User - print ''; // Year - print '"; + print ''; + print ''; + //print ''; + print ''; + if (! empty($obj->filter)) { + $filter = json_decode($obj->filter, true); + print ''; + print ''; + } + // suppression de l'export + print '"; + + $i++; + } + } + else { + dol_print_error($this->db); + } + } + } ?> diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index b5ca329ab93..17486b52a15 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -1,7 +1,8 @@ - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2012 Marcos García +/* Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Marcos García + * Copyright (C) 2012 Charles-Fr BENKE * * 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 @@ -88,6 +89,8 @@ $entitytolang = array( ); $array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array(); +$array_filtered=isset($_SESSION["export_filtered_fields"])?$_SESSION["export_filtered_fields"]:array(); +$array_filtervalue=isset($_SESSION["export_FilterValue_fields"])?$_SESSION["export_FilterValue_fields"]:array(); $datatoexport=GETPOST("datatoexport"); $action=GETPOST("action"); $step=GETPOST("step")?GETPOST("step"):1; @@ -132,7 +135,7 @@ if ($action=='selectfield') $array_selected[$field]=count($array_selected)+1; // We tag the key $field as "selected" // We check if there is a dependency - if (! empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) + if (! empty($fieldsentitiesarray[$field]) && ! empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) { $tmp=$fieldsdependenciesarray[$fieldsentitiesarray[$field]]; // $fieldsdependenciesarray=array('element'=>'fd.rowid') or array('element'=>array('fd.rowid','ab.rowid')) if (is_array($tmp)) $listofdependencies=$tmp; @@ -174,6 +177,52 @@ if ($action=='unselectfield') $_SESSION["export_selected_fields"]=$array_selected; } } + +if ($action=='selectFilterfield') +{ + if ($_GET["field"]=='all') + { + $fieldsarray=$objexport->array_export_TypeFields[0]; + foreach($fieldsarray as $key=>$val) + { + if (! empty($array_filtered[$key])) continue; // If already selected, select next + $array_filtered[$key]=count($array_filtered)+1; + //print_r($array_selected); + $_SESSION["export_filtered_fields"]=$array_filtered; + } + } + else + { + $array_filtered[$_GET["field"]]=count($array_filtered)+1; + //print_r($array_selected); + $_SESSION["export_filtered_fields"]=$array_filtered; + } +} + +if ($action=='unselectFilterfield') +{ + if ($_GET["field"]=='all') + { + $array_filtered=array(); + $_SESSION["export_filtered_fields"]=$array_filtered; + } + else + { + unset($array_filtered[$_GET["field"]]); + // Renumber fields of array_selected (from 1 to nb_elements) + asort($array_filtered); + $i=0; + $array_filterted_save=$array_filtered; + foreach($array_filtered as $code=>$value) + { + $i++; + $array_filtered[$code]=$i; + //print "x $code x $i y
"; + } + $_SESSION["export_filtered_fields"]=$array_filtered; + } +} + if ($action=='downfield' || $action=='upfield') { $pos=$array_selected[$_GET["field"]]; @@ -201,13 +250,17 @@ if ($action=='downfield' || $action=='upfield') if ($step == 1 || $action == 'cleanselect') { $_SESSION["export_selected_fields"]=array(); + $_SESSION["export_FilterValue_fields"]=array(); + $_SESSION["export_filtered_fields"]=array(); $array_selected=array(); + $array_filtervalue=array(); + $array_filtered=array(); } if ($action == 'builddoc') { // Build export file - $result=$objexport->build_file($user, $_POST['model'], $datatoexport, $array_selected); + $result=$objexport->build_file($user, $_POST['model'], $datatoexport, $array_selected, $array_filtervalue, $array_filtered); if ($result < 0) { $mesg='
'.$objexport->error.'
'; @@ -242,9 +295,21 @@ if ($action == 'add_export_model') $hexa.=$key; } + $hexafilter=''; + $hexafiltervalue=''; + foreach($array_filtered as $key=>$val) + { + if ($hexafilter) $hexafilter.=','; + if ($hexafilter) $hexafiltervalue.=','; + $hexafilter.=$key; + $hexafiltervalue.=$array_filtervalue[$key]; + } + $objexport->model_name = $export_name; $objexport->datatoexport = $datatoexport; $objexport->hexa = $hexa; + $objexport->hexafilter = $hexafilter; + $objexport->hexafiltervalue = $hexafiltervalue; $result = $objexport->create($user); if ($result >= 0) @@ -270,7 +335,13 @@ if ($action == 'add_export_model') if ($step == 2 && $action == 'select_model') { $_SESSION["export_selected_fields"]=array(); + $_SESSION["export_filtered_fields"]=array(); + $_SESSION["export_FilterValue_fields"]=array(); + $array_selected=array(); + $array_filtered=array(); + $array_filtervalue=array(); + $result = $objexport->fetch($exportmodelid); if ($result > 0) { @@ -282,9 +353,38 @@ if ($step == 2 && $action == 'select_model') $i++; } $_SESSION["export_selected_fields"]=$array_selected; + + $fieldsarray=explode(',',$objexport->hexafilter); + $fieldsarrayvalue=explode(',',$objexport->hexafiltervalue); + $i=1; + foreach($fieldsarray as $val) + { + $array_filtered[$val]=$i; + $array_filtervalue[$val]=$fieldsarrayvalue[$i-1]; + $i++; + } + $_SESSION["export_filtered_fields"]=$array_filtered; + $_SESSION["export_FilterValue_fields"]=$array_filtervalue; } } +// recuperation du filtrage issu du formulaire +if ($step == 4 && $action == 'submitFormField') +{ + // on boucle sur les champs selectionne pour recuperer la valeur + if (is_array($objexport->array_export_TypeFields[0])) + { + $_SESSION["export_FilterValue_fields"]=array(); + foreach($array_filtered as $code=>$value) + { + //print $code."=".$_POST[$objexport->array_export_fields[0][$code]]; + $objexport->array_export_FilterValue[0][$code] = $_POST[$objexport->array_export_fields[0][$code]]; + } + $_SESSION["export_FilterValue_fields"]=(! empty($objexport->array_export_FilterValue[0])?$objexport->array_export_FilterValue[0]:''); + $array_filtervalue=(! empty($objexport->array_export_FilterValue[0])?$objexport->array_export_FilterValue[0]:''); + } +} + /* * View @@ -441,7 +541,7 @@ if ($step == 2 && $datatoexport) // Champs exportables $fieldsarray=$objexport->array_export_fields[0]; // Select request if all fields are selected - $sqlmaxforexport=$objexport->build_sql(0,array()); + $sqlmaxforexport=$objexport->build_sql(0, array(), array(), array()); // $this->array_export_module[0]=$module; // $this->array_export_code[0]=$module->export_code[$r]; @@ -462,8 +562,8 @@ if ($step == 2 && $datatoexport) $i++; $entity=(! empty($objexport->array_export_entities[0][$code])?$objexport->array_export_entities[0][$code]:$objexport->array_export_icon[0]); - $entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity; - $entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity; + $entityicon=(! empty($entitytoicon[$entity])?$entitytoicon[$entity]:$entity); + $entitylang=(! empty($entitytolang[$entity])?$entitytolang[$entity]:$entity); print '
'; @@ -489,7 +589,7 @@ if ($step == 2 && $datatoexport) print $form->textwithpicto($text,$htmltext); //print ' ('.$code.')'; print ''; - $bit=1; + //$bit=1; FIXME not used ? } else { @@ -501,11 +601,11 @@ if ($step == 2 && $datatoexport) print ''; print ''; print ''; - $bit=0; + //$bit=0; FIXME not used ? } print ''; - $save_select.=$bit; + //$save_select.=$bit; FIXME not used ? } print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; + print '
'.$langs->trans("ThirdParty").''; if ($mode == 'customer') $filter='s.client in (1,2,3)'; if ($mode == 'supplier') $filter='s.fournisseur = 1'; print $form->select_company($socid,'socid',$filter,1); print '
'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").''; + print '
'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").''; print $form->select_users($userid,'userid',1); print '
'.$langs->trans("Year").''; + print '
'.$langs->trans("Year").''; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; arsort($arrayyears); print $form->selectarray('year',$arrayyears,$year,0); diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index da4642c19b8..2854c30f0fa 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -66,21 +66,21 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ $subelement = $regs[2]; } - if ($element == 'propal') $element = 'propale'; - else if ($element == 'fichinter') $element = 'ficheinter'; - else if ($element == 'product') $element = 'produit'; - else if ($element == 'member') $element = 'adherent'; + if ($element == 'propal') $newelement = 'propale'; + else if ($element == 'fichinter') $newelement = 'ficheinter'; + else if ($element == 'product') $newelement = 'produit'; + else if ($element == 'member') $newelement = 'adherent'; else if ($element == 'order_supplier') { - $element = 'fournisseur'; + $newelement = 'fournisseur'; $subelement = 'commande'; } else if ($element == 'invoice_supplier') { - $element = 'fournisseur'; + $newelement = 'fournisseur'; $subelement = 'facture'; } - if (! empty($user->rights->$element->creer) || ! empty($user->rights->$element->write) - || (isset($subelement) && (! empty($user->rights->$element->$subelement->creer) || ! empty($user->rights->$element->$subelement->write))) + if (! empty($user->rights->$newelement->creer) || ! empty($user->rights->$newelement->write) + || (isset($subelement) && (! empty($user->rights->$newelement->$subelement->creer) || ! empty($user->rights->$newelement->$subelement->write))) || ($element == 'payment' && $user->rights->facture->paiement) || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer)) { diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ded8183ec70..a0eb75b61bc 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -38,9 +38,11 @@ class ExtraFields var $attribute_label; // Tableau contenant le nom des champs en clef et la taille de ces champs en value var $attribute_size; - // Tableau contenant le statut unique ou non + // Array to store if attribute is unique or not var $attribute_unique; - + // Array to store if attribute is required or not + var $attribute_required; + var $error; var $errno; @@ -67,6 +69,7 @@ class ExtraFields $this->attribute_size = array(); $this->attribute_elementtype = array(); $this->attribute_unique = array(); + $this->attribute_required = array(); } /** @@ -79,20 +82,21 @@ class ExtraFields * @param int $size Size/length of attribute * @param string $elementtype Element type ('member', 'product', 'company', ...) * @param int $unique Is field unique or not + * @param int $required Is field required or not * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0) + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0) { if (empty($attrname)) return -1; if (empty($label)) return -1; // Create field into database - $result=$this->create($attrname,$type,$size,$elementtype); + $result=$this->create($attrname,$type,$size,$elementtype, $unique); $err1=$this->errno; if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS') { // Add declaration of field into table - $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique); + $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required); $err2=$this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { @@ -115,26 +119,23 @@ class ExtraFields * @param string $attrname code of attribute * @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour') * @param int $length Size/length of attribute - * @param string $elementtype Element type ('member', 'product', 'company', ...) + * @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...) * @param int $unique Is field unique or not + * @param int $required Is field required or not * @return int <=0 if KO, >0 if OK */ - private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0) + private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0) { - $table=''; + $table=$elementtype.'_extrafields'; + + // Special case for not normalized table names if ($elementtype == 'member') $table='adherent_extrafields'; - if ($elementtype == 'company') $table='societe_extrafields'; - if ($elementtype == 'contact') $table='socpeople_extrafields'; - if ($elementtype == 'product') $table='product_extrafields'; - if (empty($table)) - { - print 'ErrorBarValueForParameters'; - return -1; - } + elseif ($elementtype == 'company') $table='societe_extrafields'; + elseif ($elementtype == 'contact') $table='socpeople_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { - $field_desc = array('type'=>$type, 'value'=>$length); + $field_desc = array('type'=>$type, 'value'=>$length, 'null'=>($required?'NOT NULL':'NULL')); $result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); if ($result > 0) { @@ -168,9 +169,10 @@ class ExtraFields * @param int $size Size/length of attribute * @param string $elementtype Element type ('member', 'product', 'company', ...) * @param int $unique Is field unique or not + * @param int $required Is field required or not * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0) + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0) { global $conf; @@ -180,7 +182,7 @@ class ExtraFields if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired)"; $sql.= " VALUES('".$attrname."',"; $sql.= " '".$this->db->escape($label)."',"; $sql.= " '".$type."',"; @@ -188,7 +190,8 @@ class ExtraFields $sql.= " '".$size."',"; $sql.= " ".$conf->entity.","; $sql.= " '".$elementtype."',"; - $sql.= " '".$unique."'"; + $sql.= " '".$unique."',"; + $sql.= " '".$required."'"; $sql.=')'; dol_syslog(get_class($this)."::create_label sql=".$sql); @@ -209,21 +212,17 @@ class ExtraFields * Delete an optionnal attribute * * @param string $attrname Code of attribute to delete - * @param string $elementtype Element type ('member', 'product', 'company', ...) + * @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...) * @return int < 0 if KO, 0 if nothing is done, 1 if OK */ function delete($attrname, $elementtype='member') { - $table=''; - if ($elementtype == 'member') $table='adherent_extrafields'; - if ($elementtype == 'company') $table='societe_extrafields'; - if ($elementtype == 'contact') $table='socpeople_extrafields'; - if ($elementtype == 'product') $table='product_extrafields'; - if (empty($table)) - { - print 'ErrorBarValueForParameters'; - return -1; - } + $table=$elementtype.'_extrafields'; + + // Special case for not normalized table names + if ($elementtype == 'member') $table='adherent_extrafields'; + elseif ($elementtype == 'company') $table='societe_extrafields'; + elseif ($elementtype == 'contact') $table='socpeople_extrafields'; if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { @@ -289,32 +288,29 @@ class ExtraFields * @param string $label Label of attribute * @param string $type Type of attribute * @param int $length Length of attribute - * @param string $elementtype Element type ('member', 'product', 'company', ...) + * @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...) * @param int $unique Is field unique or not + * @param int $required Is field required or not * @return int >0 if OK, <=0 if KO */ - function update($attrname,$label,$type,$length,$elementtype,$unique=0) + function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0) { - $table=''; + $table=$elementtype.'_extrafields'; + + // Special case for not normalized table names if ($elementtype == 'member') $table='adherent_extrafields'; - if ($elementtype == 'company') $table='societe_extrafields'; - if ($elementtype == 'contact') $table='socpeople_extrafields'; - if ($elementtype == 'product') $table='product_extrafields'; - if (empty($table)) - { - print 'ErrorBarValueForParameters'; - return -1; - } + elseif ($elementtype == 'company') $table='societe_extrafields'; + elseif ($elementtype == 'contact') $table='socpeople_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { - $field_desc = array('type'=>$type, 'value'=>$length); + $field_desc = array('type'=>$type, 'value'=>$length, 'null'=>($required?'NOT NULL':'NULL')); $result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); if ($result > 0) { if ($label) { - $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique); + $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required); } if ($result > 0) { @@ -359,9 +355,10 @@ class ExtraFields * @param int $size Length of attribute * @param string $elementtype Element type ('member', 'product', 'company', ...) * @param int $unique Is field unique or not + * @param int $required Is field required or not * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0) + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0) { global $conf; dol_syslog(get_class($this)."::update_label $attrname,$label,$type,$size"); @@ -384,7 +381,8 @@ class ExtraFields $sql.= " type,"; $sql.= " size,"; $sql.= " elementtype,"; - $sql.= " fieldunique"; + $sql.= " fieldunique,"; + $sql.= " fieldrequired"; $sql.= ") VALUES ("; $sql.= "'".$attrname."',"; $sql.= " ".$conf->entity.","; @@ -392,7 +390,8 @@ class ExtraFields $sql.= " '".$type."',"; $sql.= " '".$size."',"; $sql.= " '".$elementtype."',"; - $sql.= " '".$unique."'"; + $sql.= " '".$unique."',"; + $sql.= " '".$required."'"; $sql.= ")"; dol_syslog(get_class($this)."::update_label sql=".$sql); $resql2=$this->db->query($sql); @@ -440,7 +439,7 @@ class ExtraFields $array_name_label=array(); - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity = ".$conf->entity; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; @@ -461,6 +460,7 @@ class ExtraFields $this->attribute_size[$tab->name]=$tab->size; $this->attribute_elementtype[$tab->name]=$tab->elementtype; $this->attribute_unique[$tab->name]=$tab->fieldunique; + $this->attribute_required[$tab->name]=$tab->fieldrequired; } } return $array_name_label; @@ -489,6 +489,7 @@ class ExtraFields $size =$this->attribute_size[$key]; $elementtype=$this->attribute_elementtype[$key]; $unique=$this->attribute_unique[$key]; + $required=$this->attribute_required[$key]; if ($type == 'date') { $showsize=10; @@ -550,6 +551,7 @@ class ExtraFields $size=$this->attribute_size[$key]; $elementtype=$this->attribute_elementtype[$key]; $unique=$this->attribute_unique[$key]; + $required=$this->attribute_required[$key]; if ($type == 'date') { $showsize=10; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 39f9dc167e1..d6824ce682e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -89,7 +89,7 @@ class Form // TODO change for compatibility if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! preg_match('/^select;/',$typeofdata)) { - if ($perm) + if (! empty($perm)) { $tmp=explode(':',$typeofdata); $ret.= '
'; diff --git a/htdocs/core/js/dst.js b/htdocs/core/js/dst.js index da74cc3b857..250d379ed42 100644 --- a/htdocs/core/js/dst.js +++ b/htdocs/core/js/dst.js @@ -38,12 +38,17 @@ $(document).ready(function () { } else { dst = "1"; // daylight savings time is observed } - var tz=new Date().toTimeString().match(/\(.*\)/); + var now=new Date(); + var tz=now.toTimeString().match(/\(.*\)/); + //alert('date=' + now + ' string=' + now.toTimeString()); var dst_first=DisplayDstSwitchDates('first'); var dst_second=DisplayDstSwitchDates('second'); //alert(dst); $('#tz').val(std_time_offset); // returns TZ - $('#tz_string').val(tz[0].replace('(','').replace(')','')); // returns TZ string + // tz is null with IE + if (tz != null) { + $('#tz_string').val(tz[0].replace('(','').replace(')','')); // returns TZ string + } $('#dst_observed').val(dst); // returns if DST is observed on summer $('#dst_first').val(dst_first); // returns DST first switch in year $('#dst_second').val(dst_second); // returns DST second switch in year diff --git a/htdocs/core/js/lib_head.js b/htdocs/core/js/lib_head.js index 2f9de0c6e27..62427857749 100644 --- a/htdocs/core/js/lib_head.js +++ b/htdocs/core/js/lib_head.js @@ -718,9 +718,10 @@ function delConstant(url, code, input, entity) { * */ function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton) { + var boxConfirm = box; $("#confirm_" + code) - .attr("title", box.title) - .html(box.content) + .attr("title", boxConfirm.title) + .html(boxConfirm.content) .dialog({ resizable: false, height: 170, @@ -737,9 +738,9 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton, } // Close dialog $(this).dialog("close"); - // Execute another function - if (box.function) { - var fnName = box.function; + // Execute another method + if (boxConfirm.method) { + var fnName = boxConfirm.method; if (window.hasOwnProperty(fnName)) { window[fnName](); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6416cac14ef..24d1cccd4f1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -642,7 +642,7 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p } else { - $out.=''.$links[$i][1].''."\n"; + $out.=''.$links[$i][1].''."\n"; } } } diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index 62afe13c902..744a8830588 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -87,7 +87,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverLabel() + function getDriverLabel($key='') { return $this->label; } @@ -97,7 +97,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverDesc() + function getDriverDesc($key='') { return $this->desc; } @@ -117,7 +117,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverVersion() + function getDriverVersion($key='') { return $this->version; } @@ -127,7 +127,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getLibLabel() + function getLibLabel($key='') { return $this->label_lib; } @@ -137,7 +137,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getLibVersion() + function getLibVersion($key='') { return $this->version_lib; } diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index 620bc709e45..a53c2a21765 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -87,7 +87,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverLabel() + function getDriverLabel($key='') { return $this->label; } @@ -97,7 +97,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverDesc() + function getDriverDesc($key='') { return $this->desc; } @@ -117,7 +117,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverVersion() + function getDriverVersion($key='') { return $this->version; } @@ -127,7 +127,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getLibLabel() + function getLibLabel($key='') { return $this->label_lib; } @@ -137,7 +137,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getLibVersion() + function getLibVersion($key='') { return $this->version_lib; } diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index 16e1a7a0c7a..7d8316ee359 100755 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -88,7 +88,7 @@ class ExportExcel2007 extends ExportExcel * * @return string */ - function getDriverLabel() + function getDriverLabel($key='') { return $this->label; } @@ -98,7 +98,7 @@ class ExportExcel2007 extends ExportExcel * * @return string */ - function getDriverDesc() + function getDriverDesc($key='') { return $this->desc; } @@ -118,7 +118,7 @@ class ExportExcel2007 extends ExportExcel * * @return string */ - function getDriverVersion() + function getDriverVersion($key='') { return $this->version; } @@ -128,7 +128,7 @@ class ExportExcel2007 extends ExportExcel * * @return string */ - function getLibLabel() + function getLibLabel($key='') { return $this->label_lib; } @@ -138,7 +138,7 @@ class ExportExcel2007 extends ExportExcel * * @return string */ - function getLibVersion() + function getLibVersion($key='') { return $this->version_lib; } diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index 6a791cd5a93..687b9c6fb8d 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -82,7 +82,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverLabel() + function getDriverLabel($key='') { return $this->label; } @@ -92,7 +92,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverDesc() + function getDriverDesc($key='') { return $this->desc; } @@ -112,7 +112,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverVersion() + function getDriverVersion($key='') { return $this->version; } @@ -122,7 +122,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getLibLabel() + function getLibLabel($key='') { return $this->label_lib; } @@ -132,7 +132,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getLibVersion() + function getLibVersion($key='') { return $this->version_lib; } diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index cb5b51c2318..044b077f567 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -173,7 +173,8 @@ class modAdherent extends DolibarrModules $this->export_label[$r]='MembersAndSubscriptions'; $this->export_permission[$r]=array(array("adherent","export")); $this->export_fields_array[$r]=array('a.rowid'=>'Id','a.civilite'=>"UserTitle",'a.nom'=>"Lastname",'a.prenom'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature','a.societe'=>'Company','a.adresse'=>"Address",'a.cp'=>"Zip",'a.ville'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation','a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel','c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.cotisation'=>'Amount'); - $this->export_entities_array[$r]=array('a.rowid'=>'member','a.civilite'=>"member",'a.nom'=>"member",'a.prenom'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.adresse'=>"member",'a.cp'=>"member",'a.ville'=>"member",'a.pays'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.naiss'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.cotisation'=>'subscription'); + $this->export_TypeFields_array[$r]=array('a.civilite'=>"Text",'a.nom'=>"Text",'a.prenom'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.adresse'=>"Text",'a.cp'=>"Text",'a.ville'=>"Text",'a.pays'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",'a.email'=>"Text",'a.naiss'=>"Date",'a.statut'=>"Status",'a.note'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date','a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:fk_adherent_type:libelle','ta.libelle'=>'Text','c.dateadh'=>'Date','c.cotisation'=>'Number'); + $this->export_entities_array[$r]=array('a.rowid'=>'member','a.civilite'=>"member",'a.nom'=>"member",'a.prenom'=>"member",'a.login'=>"member",'a.morphy'=>'member','a.societe'=>'member','a.adresse'=>"member",'a.cp'=>"member",'a.ville'=>"member",'a.pays'=>"member",'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.naiss'=>"member",'a.statut'=>"member",'a.photo'=>"member",'a.note'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member','a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.cotisation'=>'subscription'); // Add extra fields $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'member'"; $resql=$this->db->query($sql); @@ -208,7 +209,7 @@ class modAdherent extends DolibarrModules $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array('a.civilite'=>"UserTitle",'a.nom'=>"Lastname*",'a.prenom'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password","a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.adresse'=>"Address",'a.cp'=>"Zip",'a.ville'=>"Town",'a.pays'=>"Country",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.naiss'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note'=>"Note",'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription'); // Add extra fields - $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'member'"; + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'member'"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -216,7 +217,7 @@ class modAdherent extends DolibarrModules { $fieldname='extra.'.$obj->name; $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel; + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); } } // End add extra fields diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 44fdfde6b17..b2e79d49eae 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -145,6 +145,7 @@ class modBanque extends DolibarrModules $this->export_label[$r]='Ecritures bancaires et releves'; $this->export_permission[$r]=array(array("banque","export")); $this->export_fields_array[$r]=array('b.rowid'=>'IdTransaction','ba.ref'=>'AccountRef','ba.label'=>'AccountLabel','b.datev'=>'DateValue','b.dateo'=>'DateOperation','b.label'=>'Label','b.num_chq'=>'ChequeOrTransferNumber','-b.amount'=>'Debit','b.amount'=>'Credit','b.num_releve'=>'AccountStatement','b.datec'=>"DateCreation","bu.url_id"=>"IdThirdParty","s.nom"=>"ThirdParty","s.code_compta"=>"CustomerAccountancyCode","s.code_compta_fournisseur"=>"SupplierAccountancyCode"); + $this->export_TypeFields_array[$r]=array('ba.ref'=>'Text','ba.label'=>'Text','b.datev'=>'Date','b.dateo'=>'Date','b.label'=>'Text','b.num_chq'=>'Text','-b.amount'=>'Number','b.amount'=>'Number','b.num_releve'=>'Text','b.datec'=>"Date","bu.url_id"=>"Text","s.nom"=>"Text","s.code_compta"=>"Text","s.code_compta_fournisseur"=>"Text"); $this->export_entities_array[$r]=array('b.rowid'=>'account','ba.ref'=>'account','ba.label'=>'account','b.datev'=>'account','b.dateo'=>'account','b.label'=>'account','b.num_chq'=>'account','-b.amount'=>'account','b.amount'=>'account','b.num_releve'=>'account','b.datec'=>"account","bu.url_id"=>"company","s.nom"=>"company","s.code_compta"=>"company","s.code_compta_fournisseur"=>"company"); $this->export_special_array[$r]=array('-b.amount'=>'NULLIFNEG','b.amount'=>'NULLIFNEG'); if (empty($conf->fournisseur->enabled)) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index be6ecb3e8de..cb5fe07ee5f 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -110,6 +110,7 @@ class modCategorie extends DolibarrModules $this->export_enabled[$r]='$conf->fournisseur->enabled'; $this->export_permission[$r]=array(array("categorie","lire"),array("fournisseur","lire")); $this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix",'s.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'s.tel'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note'=>"Note"); + $this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'s.rowid'=>'List:societe:nom','s.nom'=>'Text','s.prefix_comm'=>"Text",'s.client'=>"Text",'s.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.address'=>"Text",'s.cp'=>"Text",'s.ville'=>"Text",'p.libelle'=>"List:c_pays:libelle:rowid",'p.code'=>"Text",'s.tel'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note'=>"Text"); $this->export_entities_array[$r]=array('s.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.libelle'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company"); // We define here only fields that use another picto $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_fournisseur as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON s.fk_pays = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; @@ -124,6 +125,7 @@ class modCategorie extends DolibarrModules $this->export_enabled[$r]='$conf->societe->enabled'; $this->export_permission[$r]=array(array("categorie","lire"),array("societe","lire")); $this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix",'s.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'s.tel'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note'=>"Note",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus'); + $this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'s.rowid'=>'List:societe:nom','s.nom'=>'Text','s.prefix_comm'=>"Text",'s.client'=>"Text",'s.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.address'=>"Text",'s.cp'=>"Text",'s.ville'=>"Text",'p.libelle'=>"List:c_pays:libelle:rowid",'p.code'=>"Text",'s.tel'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note'=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code','s.fk_stcomm'=>'List:c_stcomm:libelle:code'); $this->export_entities_array[$r]=array('s.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",'s.code_client'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.libelle'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company",'s.fk_prospectlevel'=>'company','s.fk_stcomm'=>'company'); // We define here only fields that use another picto $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_societe as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON s.fk_pays = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; @@ -138,6 +140,7 @@ class modCategorie extends DolibarrModules $this->export_enabled[$r]='$conf->produit->enabled'; $this->export_permission[$r]=array(array("categorie","lire"),array("produit","lire")); $this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'ProductId','p.ref'=>'Ref'); + $this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'p.rowid'=>'List:Product:label','p.ref'=>'Text'); $this->export_entities_array[$r]=array('p.rowid'=>'product','p.ref'=>'product'); // We define here only fields that use another picto $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p'; @@ -152,31 +155,29 @@ class modCategorie extends DolibarrModules $this->export_enabled[$r]='$conf->adherent->enabled'; $this->export_permission[$r]=array(array("categorie","lire"),array("adherent","lire")); $this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'MemberId','p.nom'=>'LastName','p.prenom'=>'Firstname'); + $this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'p.rowid'=>'List:adherent:nom','p.nom'=>'Text','p.prenom'=>'Text'); $this->export_entities_array[$r]=array('p.rowid'=>'member','p.nom'=>'member','p.prenom'=>'member'); // We define here only fields that use another picto $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p'; $this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid'; $this->export_sql_end[$r] .=' AND u.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND u.type = 3'; // Supplier categories - + // Imports //-------- - + $r=0; - + $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; $this->import_label[$r]="CatList"; // Translation key $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('ca'=>MAIN_DB_PREFIX.'categorie'); - $this->import_fields_array[$r]=array('ca.label'=>"Label*", - 'ca.type'=>"Type*",'ca.description'=>"Description" - ); - + $this->import_fields_array[$r]=array('ca.label'=>"Label*",'ca.type'=>"Type*",'ca.description'=>"Description"); + $this->import_regex_array[$r]=array('ca.type'=>'^[0|1|2|3]'); - $this->import_examplevalues_array[$r]=array('ca.label'=>"Supplier Category", - 'ca.type'=>"1", 'ca.description'=>"Imported category"); + $this->import_examplevalues_array[$r]=array('ca.label'=>"Supplier Category",'ca.type'=>"1",'ca.description'=>"Imported category"); } diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index bf8cc381db5..70595e8d82a 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -174,6 +174,7 @@ class modCommande extends DolibarrModules $this->export_label[$r]='CustomersOrdersAndOrdersLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("commande","commande","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note'=>"Note",'c.date_livraison'=>'DeliveryDate','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct','cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','s.libelle'=>'List:c_pays:libelle:rowid','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Number",'c.remise_percent'=>"Number",'c.total_ht'=>"Number",'c.total_ttc'=>"Number",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Number",'cd.qty'=>"Number",'cd.total_ht'=>"Number",'cd.total_tva'=>"Number",'cd.total_ttc'=>"Number",'p.rowid'=>'List:Product:ref','p.ref'=>'Text','p.label'=>'Text'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order",'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order",'c.date_livraison'=>"order",'cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line",'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line",'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'); $this->export_dependencies_array[$r]=array('order_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index 0145c1bb55d..95692f0f150 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -121,6 +121,7 @@ class modDeplacement extends DolibarrModules $this->export_label[$r]='ListTripsAndExpenses'; $this->export_permission[$r]=array(array("deplacement","export")); $this->export_fields_array[$r]=array('u.login'=>'Login','u.name'=>'Lastname','u.firstname'=>'Firstname','d.rowid'=>"TripId",'d.type'=>"Type",'d.km'=>"FeesKilometersOrAmout",'d.dated'=>"Date",'d.note'=>'NotePrivate','d.note_public'=>'NotePublic','s.nom'=>'ThirdParty'); + $this->export_TypeFields_array[$r]=array('u.rowid'=>'List:user:name','u.login'=>'Text','u.name'=>'Text','u.firstname'=>'Text','d.type'=>"Text",'d.km'=>"Number",'d.dated'=>"Date",'d.note'=>'Text','d.note_public'=>'Text','s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text'); $this->export_entities_array[$r]=array('u.login'=>'user','u.name'=>'user','u.firstname'=>'user','d.rowid'=>"trip",'d.type'=>"trip",'d.km'=>"trip",'d.dated'=>"trip",'d.note'=>'trip','d.note_public'=>'trip','s.nom'=>'company'); $this->export_dependencies_array[$r]=array('trip'=>'d.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 656298bbc36..8ee4150649c 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -175,6 +175,7 @@ class modFacture extends DolibarrModules $this->export_icon[$r]='bill'; $this->export_permission[$r]=array(array("facture","facture","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','c.code'=>'CountryCode','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"NotePrivate",'f.note_public'=>"NotePublic",'fd.rowid'=>'LineId','fd.label'=>"Label",'fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalVAT",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.product_type'=>"TypeOfLineServiceOrProduct",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.price'=>"Numeric",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",'fd.date_end'=>"Date",'fd.product_type'=>"Numeric",'fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','c.code'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.label'=>"invoice_line",'fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product'); $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them @@ -193,6 +194,7 @@ class modFacture extends DolibarrModules $this->export_icon[$r]='bill'; $this->export_permission[$r]=array(array("facture","facture","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','c.code'=>'CountryCode','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"NotePrivate",'f.note_public'=>"NotePublic",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber'); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','c.code'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment'); $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index e22023a74e3..54d9c0ce447 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -139,6 +139,7 @@ class modFicheinter extends DolibarrModules $this->export_label[$r]='InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("ficheinter","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InterId",'f.ref'=>"InterRef",'f.datec'=>"InterDateCreation",'f.duree'=>"InterDuration",'f.fk_statut'=>'InterStatus','f.description'=>"InterNote",'fd.rowid'=>'InterLineId','fd.date'=>"InterLineDate",'fd.duree'=>"InterLineDuration",'fd.description'=>"InterLineDesc"); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','s.fk_pays'=>'List:c_pays:libelle','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric"); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"intervention",'f.ref'=>"intervention",'f.datec'=>"intervention",'f.duree'=>"intervention",'f.fk_statut'=>"intervention",'f.description'=>"intervention",'fd.rowid'=>"inter_line",'fd.date'=>"inter_line",'fd.duree'=>'inter_line','fd.description'=>'inter_line'); $this->export_dependencies_array[$r]=array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 4cf2a554868..8bdc2e0364a 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -243,6 +243,7 @@ class modFournisseur extends DolibarrModules $this->export_icon[$r]='bill'; $this->export_permission[$r]=array(array("fournisseur","facture","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','c.code'=>'CountryCode','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','c.code'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product'); $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them @@ -260,6 +261,7 @@ class modFournisseur extends DolibarrModules $this->export_icon[$r]='bill'; $this->export_permission[$r]=array(array("fournisseur","facture","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','c.code'=>'CountryCode','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber'); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','c.code'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment'); $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them @@ -278,6 +280,7 @@ class modFournisseur extends DolibarrModules $this->export_icon[$r]='order'; $this->export_permission[$r]=array(array("fournisseur","commande","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','c.code'=>'CountryCode','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.note'=>"Note",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); + //$this->export_TypeFields_array[$r]=array(); // TODO add fields type $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','c.code'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"order",'f.ref'=>"order",'f.ref_supplier'=>"order",'f.date_creation'=>"order",'f.date_commande'=>"order",'f.total_ht'=>"order",'f.total_ttc'=>"order",'f.tva'=>"order",'f.fk_statut'=>'order','f.note'=>"order",'fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product'); $this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index e05b65a4f3d..ec6971689b7 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -138,6 +138,9 @@ class modProduct extends DolibarrModules $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); + $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Number",'p.surface'=>"Number",'p.volume'=>"Number",'p.weight'=>"Number",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.pmp'=>'Number')); + if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.accountancy_code_sell'=>'product','p.accountancy_code_sell'=>'product','p.note'=>"product",'p.length'=>"product",'p.surface'=>"product",'p.volume'=>"product",'p.weight'=>"product",'p.customcode'=>'product','p.price_base_type'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>"product",'p.tosell'=>"product",'p.tobuy'=>"product",'p.datec'=>"product",'p.tms'=>"product"); if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product')); @@ -175,7 +178,7 @@ class modProduct extends DolibarrModules $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation*'); // Add extra fields - $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'"; + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -183,15 +186,15 @@ class modProduct extends DolibarrModules { $fieldname='extra.'.$obj->name; $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel; + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); } } // End add extra fields $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); $this->import_examplevalues_array[$r]=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31'); - - + + if (! empty($conf->fournisseur->enabled)) { // Import product suppliers diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index a47ed483d16..52f2040caff 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -134,6 +134,35 @@ class modProjet extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'all'; $this->rights[$r][5] = 'supprimer'; + + + //Exports + //-------- + $r=1; + + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r]=array(array("projet","export")); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country', + 's.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode', + 'p.rowid'=>"ProjectId",'p.ref'=>"ProjectRef",'p.datec'=>"DateCreation",'p.dateo'=>"DateDebutProjet",'p.datee'=>"DateFinProjet",'p.fk_statut'=>'ProjectStatus','p.description'=>"projectNote", + 'pt.rowid'=>'RefTask','pt.dateo'=>"TaskDateo",'pt.datee'=>"TaskDatee",'pt.duration_effective'=>"DurationEffective",'pt.duration_planned'=>"DurationPlanned",'pt.progress'=>"Progress",'pt.description'=>"TaskDesc"); + + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','s.fk_pays'=>'List:c_pays:libelle', + 's.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text', + 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.description'=>"Text", + 'pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.duration_planned'=>"Duree",'pt.progress'=>"Number",'pt.description'=>"Text"); + + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company', + 's.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company', + 'f.rowid'=>"project",'f.ref'=>"project",'f.datec'=>"project",'f.duree'=>"project",'f.fk_statut'=>"project",'f.description'=>"project", + 'pt.rowid'=>'task','pt.dateo'=>"task",'pt.datee'=>"task",'pt.duration_effective'=>"task",'pt.duration_planned'=>"task",'pt.progress'=>"task",'pt.description'=>"task"); + + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'projet as p, '.MAIN_DB_PREFIX.'projet_task as pt, '.MAIN_DB_PREFIX.'societe as s)'; + $this->export_sql_end[$r] .=' WHERE p.fk_soc = s.rowid AND p.rowid = pt.fk_projet '; + $this->export_sql_end[$r] .=' AND p.entity = '.$conf->entity; + $r++; } diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 8a44949690b..491e5337166 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -168,6 +168,7 @@ class modPropale extends DolibarrModules $this->export_label[$r]='ProposalsAndProposalsLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("propale","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','cp.code'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.datec'=>"DateCreation",'c.datep'=>"DatePropal",'c.fin_validite'=>"DateEndPropal",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total'=>"TotalTTC",'c.fk_statut'=>'Status','c.note'=>"Note",'c.date_livraison'=>'DeliveryDate','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct','cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','cp.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','cp.code'=>'company','s.tel'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"propal",'c.ref'=>"propal",'c.ref_client'=>"propal",'c.fk_soc'=>"propal",'c.datec'=>"propal",'c.datep'=>"propal",'c.fin_validite'=>"propal",'c.remise_percent'=>"propal",'c.total_ht'=>"propal",'c.total'=>"propal",'c.fk_statut'=>"propal",'c.note'=>"propal",'c.date_livraison'=>"propal",'cd.rowid'=>'propal_line','cd.label'=>"propal_line",'cd.description'=>"propal_line",'cd.product_type'=>'propal_line','cd.tva_tx'=>"propal_line",'cd.qty'=>"propal_line",'cd.total_ht'=>"propal_line",'cd.total_tva'=>"propal_line",'cd.total_ttc'=>"propal_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'); $this->export_dependencies_array[$r]=array('propal_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 7fdc365c040..e090cc5aa01 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -122,6 +122,8 @@ class modService extends DolibarrModules $this->export_permission[$r]=array(array("service","export")); $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock')); + $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Number",'p.price_ttc'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Number')); $this->export_entities_array[$r]=array('p.rowid'=>"service",'p.ref'=>"service",'p.label'=>"service",'p.description'=>"service",'p.accountancy_code_sell'=>'service','p.accountancy_code_sell'=>'service','p.note'=>"service",'p.price_base_type'=>"service",'p.price'=>"service",'p.price_ttc'=>"service",'p.tva_tx'=>"service",'p.tosell'=>"service",'p.duration'=>"service",'p.datec'=>"service",'p.tms'=>"service"); if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product')); // Add extra fields @@ -137,7 +139,7 @@ class modService extends DolibarrModules $this->export_entities_array[$r][$fieldname]='product'; } } - // End add axtra fields + // End add extra fields $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; @@ -158,7 +160,7 @@ class modService extends DolibarrModules $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation*'); // Add extra fields - $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'"; + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product'"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -166,7 +168,7 @@ class modService extends DolibarrModules { $fieldname='extra.'.$obj->name; $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel; + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); } } // End add extra fields diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 27657765ed8..2fc3f740ae1 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -247,8 +247,9 @@ class modSociete extends DolibarrModules $this->export_label[$r]='ExportDataset_company_1'; $this->export_icon[$r]='company'; $this->export_permission[$r]=array(array("societe","export")); - $this->export_fields_array[$r]=array('s.rowid'=>"Id",'s.nom'=>"Name",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'s.tel'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note'=>"Note",'t.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','d.nom'=>'State'); + $this->export_fields_array[$r]=array('s.rowid'=>"Id",'s.nom'=>"Name",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'p.libelle'=>"Country",'p.code'=>"CountryCode",'s.tel'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note'=>"Note",'t.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','d.nom'=>'State'); if (! empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix']='Prefix'; + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.cp'=>"Text",'s.ville'=>"Text",'p.libelle'=>"List:c_pays:libelle:rowid",'p.code'=>"Text",'s.tel'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Number",'s.note'=>"Text",'t.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code','s.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid'); $this->export_entities_array[$r]=array(); // We define here only fields that use another picto // Add extra fields $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'company'"; @@ -321,7 +322,7 @@ class modSociete extends DolibarrModules $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r]=array('s.nom'=>"Name*",'s.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'s.fk_pays'=>"CountryCode",'s.tel'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note'=>"Note",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff","s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage','s.barcode'=>'BarCode','s.datec'=>"DateCreation"); // Add extra fields - $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'company'"; + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'company'"; $resql=$this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -329,7 +330,7 @@ class modSociete extends DolibarrModules { $fieldname='extra.'.$obj->name; $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel; + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); } } // End add extra fields @@ -355,6 +356,19 @@ class modSociete extends DolibarrModules $this->import_entities_array[$r]=array('s.fk_soc'=>'company'); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r]=array('s.fk_soc'=>'ThirdPartyName*','s.civilite'=>'UserTitle','s.name'=>"Name*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.cp'=>"Zip",'s.ville'=>"Town",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso",'s.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note'=>"Note",'s.datec'=>"DateCreation"); + // Add extra fields + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'contact'"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + } + } + // End add extra fields $this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_convertvalue_array[$r]=array( 's.fk_soc'=>array('rule'=>'fetchidfromref','file'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), @@ -363,7 +377,7 @@ class modSociete extends DolibarrModules //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r]=array('s.birthday'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); $this->import_examplevalues_array[$r]=array('s.fk_soc'=>'MyBigCompany','s.civilite'=>"MR",'s.name'=>"Smith",'s.firstname'=>'John','s.address'=>'61 jump street','s.cp'=>'75000','s.ville'=>'Bigtown','s.fk_pays'=>'US, FR, DE...','s.datec'=>'1972-10-10','s.poste'=>"Director",'s.phone'=>"5551122",'s.phone_perso'=>"5551133",'s.phone_mobile'=>"5551144",'s.fax'=>"5551155",'s.email'=>"johnsmith@email.com",'s.note'=>"My comments"); - + // Import Bank Accounts $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; @@ -373,15 +387,15 @@ class modSociete extends DolibarrModules $this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_rib'); $this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.bank'=>"Bank", 'sr.code_banque'=>"BankCode*",'sr.code_guichet'=>"DeskCode*",'sr.number'=>"BankAccountNumber*", - 'sr.cle_rib'=>"BankAccountNumberKey*",'sr.bic'=>"BIC",'sr.iban_prefix'=>"IBAN" + 'sr.cle_rib'=>"BankAccountNumberKey*",'sr.bic'=>"BIC",'sr.iban_prefix'=>"IBAN" ); - + $this->import_convertvalue_array[$r]=array( 'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') ); $this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.bank'=>"ING", 'sr.code_banque'=>"0000", 'sr.code_guichet'=>"1111",'sr.number'=>"3333333333", - 'sr.cle_rib'=>"22",'sr.bic'=>"USHINGMMXXX",'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333" + 'sr.cle_rib'=>"22",'sr.bic'=>"USHINGMMXXX",'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333" ); } diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 03a6a22c62a..f1cbb58f469 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -123,6 +123,7 @@ class modStock extends DolibarrModules $this->export_label[$r]="WarehousesAndProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("stock","lire")); $this->export_fields_array[$r]=array('e.rowid'=>'IdWarehouse','e.label'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.cp'=>'Zip','e.ville'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification','ps.reel'=>'Stock'); + $this->export_TypeFields_array[$r]=array('e.rowid'=>'List:entrepot:LabelWareHouse','e.label'=>'Text','e.label'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.cp'=>'Text','e.ville'=>'Text','p.rowid'=>"List:produit:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Number",'p.tva_tx'=>'Number','p.tosell'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','ps.reel'=>'Number'); $this->export_entities_array[$r]=array('e.rowid'=>'warehouse','e.label'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.cp'=>'warehouse','e.ville'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.duration'=>"product",'p.datec'=>'product','p.tms'=>'product','ps.reel'=>'stock'); $this->export_aggregate_array[$r]=array('ps.reel'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r]=array('stock'=>array('p.rowid','e.rowid')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them @@ -131,13 +132,13 @@ class modStock extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e'; $this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid'; $this->export_sql_end[$r] .=' AND e.entity = '.$conf->entity; - - + + // Imports //-------- - + $r=0; - + $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; $this->import_label[$r]="Warehouses"; // Translation key @@ -150,7 +151,7 @@ class modStock extends DolibarrModules 'e.address'=>"Address",'e.cp'=>'Zip','e.fk_pays'=>'CountryCode', 'e.statut'=>'Status' ); - + $this->import_convertvalue_array[$r]=array( 'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cpays.class.php','class'=>'Cpays','method'=>'fetch','dict'=>'DictionnaryCountry') ); diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index 72de8c56cb8..26845c2aac8 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -126,6 +126,7 @@ class modTax extends DolibarrModules $this->export_label[$r]='Taxes et charges sociales, et leurs reglements'; $this->export_permission[$r]=array(array("tax","charges","export")); $this->export_fields_array[$r]=array('cc.libelle'=>"Type",'c.rowid'=>"IdSocialContribution",'c.libelle'=>"Label",'c.date_ech'=>'DateDue','c.periode'=>'Period','c.amount'=>"AmountExpected","c.paye"=>"Status",'p.rowid'=>'PaymentId','p.datep'=>'DatePayment','p.amount'=>'AmountPayment','p.num_paiement'=>'Numero'); + $this->export_TypeFields_array[$r]=array('cc.libelle'=>"List:c_chargesociales:libelle:id",'c.libelle'=>"Text",'c.date_ech'=>'Date','c.periode'=>'Period','c.amount'=>"Number","c.paye"=>"Boolean",'p.datep'=>'Date','p.amount'=>'Number','p.num_paiement'=>'Number'); $this->export_entities_array[$r]=array('cc.libelle'=>"tax_type",'c.rowid'=>"tax",'c.libelle'=>'tax','c.date_ech'=>'tax','c.periode'=>'tax','c.amount'=>"tax","c.paye"=>"tax",'p.rowid'=>'payment','p.datep'=>'payment','p.amount'=>'payment','p.num_paiement'=>'payment'); $this->export_sql_start[$r]='SELECT DISTINCT '; diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 597e723b868..26406df523b 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2009 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -210,6 +210,8 @@ class modUser extends DolibarrModules $this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs'; $this->export_permission[$r]=array(array("user","user","export")); $this->export_fields_array[$r]=array('u.rowid'=>"Id",'u.login'=>"Login",'u.name'=>"Lastname",'u.firstname'=>"Firstname",'u.office_phone'=>'Telephone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",'u.admin'=>"Admin",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion','u.fk_socpeople'=>"IdContact",'u.fk_societe'=>"IdCompany",'u.fk_member'=>"MemberId"); + $this->export_TypeFields_array[$r]=array('u.login'=>"Text",'u.name'=>"Text",'u.firstname'=>"Text",'u.office_phone'=>'Text','u.office_fax'=>'Text','u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date','u.datepreviouslogin'=>'Date','u.fk_societe'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:nom"); + $this->export_entities_array[$r]=array('u.rowid'=>"user",'u.login'=>"user",'u.name'=>"user",'u.firstname'=>"user",'u.office_phone'=>'user','u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_societe'=>"company",'u.fk_member'=>"member"); if (empty($conf->adherent->enabled)) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 9691c04e307..3fd320a1991 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -525,7 +525,7 @@ class pdf_azur extends ModelePDFPropales } // Show payments conditions - if (isset($object->type) && $object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) + if (! empty($conf->global->PROPALE_PDF_PAIEMENT_ENABLED) && ($object->cond_reglement_code || $object->cond_reglement)) { $pdf->SetFont('','B', $default_font_size - 2); $pdf->SetXY($this->marge_gauche, $posy); @@ -542,7 +542,7 @@ class pdf_azur extends ModelePDFPropales } - if (isset($object->type) && $object->type != 2) + if (! empty($conf->global->PROPALE_PDF_PAIEMENT_ENABLED)) { // Check a payment mode is defined if (empty($object->mode_reglement_code) diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index fdcddaf6df1..cc31c234d49 100755 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -65,9 +65,10 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref + * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) +function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) { global $conf, $user, $langs; @@ -136,7 +137,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 2ccbdf031ff..71d385f7786 100755 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -132,7 +132,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) { global $user,$langs,$conf,$mysoc; @@ -284,10 +284,10 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. -// We suppose that a too long description is moved completely on next page -if ($pageposafter > $pageposbefore) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; -} + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut @@ -809,9 +809,10 @@ if ($pageposafter > $pageposbefore) { * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output + * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) { global $langs,$conf,$mysoc; @@ -887,6 +888,12 @@ if ($pageposafter > $pageposbefore) { $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R'); } + $posy+=2; + $pdf->SetTextColor(0,0,60); + + // Show list of linked objects + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + if ($showaddress) { // Sender properties diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index 7c437a751cd..e7b7a1ad8f8 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -147,9 +147,10 @@ abstract class ModeleNumRefSuppliersOrders * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref + * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) +function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) { global $conf, $user, $langs; $langs->load("suppliers"); @@ -217,14 +218,14 @@ function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedet // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) { $outputlangs->charset_output=$sav_charset_output; // we delete preview files require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_delete_preview($object); - + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($db); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 1644955bfd4..64e3b4024f6 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -296,10 +296,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. -// We suppose that a too long description is moved completely on next page -if ($pageposafter > $pageposbefore) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; -} + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut @@ -908,9 +908,10 @@ if ($pageposafter > $pageposbefore) { * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output + * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) { global $langs,$conf,$mysoc; @@ -992,6 +993,10 @@ if ($pageposafter > $pageposbefore) { } $posy+=2; + $pdf->SetTextColor(0,0,60); + + // Show list of linked objects + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); if ($showaddress) { diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 2b204b2b654..8e7115137b6 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2005-2011 Regis Houssin +/* Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Charles-Fr BENKE * * 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 @@ -35,12 +36,16 @@ class Export var $array_export_label=array(); // Tableau de "libelle de lots" var $array_export_sql=array(); // Tableau des "requetes sql" var $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter + var $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre + var $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer var $array_export_entities=array(); // Tableau des listes de champ+alias a exporter var $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export var $array_export_special=array(); // Tableau des operations speciales sur champ // To store export modules var $hexa; + var $hexafilter; + var $hexafiltervalue; var $datatoexport; var $model_name; @@ -106,7 +111,7 @@ class Export require_once $file; $module = new $classname($this->db); - if (is_array($module->export_code)) + if (isset($module->export_code) && is_array($module->export_code)) { foreach($module->export_code as $r => $value) { @@ -122,7 +127,7 @@ class Export { $perm=$val; //print_r("$perm[0]-$perm[1]-$perm[2]
"); - if ($perm[2]) + if (! empty($perm[2])) { $bool=$user->rights->$perm[0]->$perm[1]->$perm[2]; } @@ -160,19 +165,21 @@ class Export $this->array_export_label[$i]=$module->getExportDatasetLabel($r); // Tableau des champ a exporter (cle=champ, valeur=libelle) $this->array_export_fields[$i]=$module->export_fields_array[$r]; + // Tableau des champs a filtrer (cle=champ, valeur1=type de donnees) on verifie que le module a des filtres + $this->array_export_TypeFields[$i]=(isset($module->export_TypeFields_array[$r])?$module->export_TypeFields_array[$r]:''); // Tableau des entites a exporter (cle=champ, valeur=entite) $this->array_export_entities[$i]=$module->export_entities_array[$r]; // Tableau des entites qui requiert abandon du DISTINCT (cle=entite, valeur=champ id child records) - $this->array_export_dependencies[$i]=$module->export_dependencies_array[$r]; + $this->array_export_dependencies[$i]=(! empty($module->export_dependencies_array[$r])?$module->export_dependencies_array[$r]:''); // Tableau des operations speciales sur champ - $this->array_export_special[$i]=$module->export_special_array[$r]; + $this->array_export_special[$i]=(! empty($module->export_special_array[$r])?$module->export_special_array[$r]:''); // Requete sql du dataset $this->array_export_sql_start[$i]=$module->export_sql_start[$r]; $this->array_export_sql_end[$i]=$module->export_sql_end[$r]; //$this->array_export_sql[$i]=$module->export_sql[$r]; - dol_syslog(get_class($this)."::load_arrays loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".count($module->export_fields_code[$r])); + dol_syslog(get_class($this)."::load_arrays loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".(! empty($module->export_fields_code[$r])?count($module->export_fields_code[$r]):'')); $i++; // } } @@ -196,7 +203,7 @@ class Export * @param array $array_selected Filter on array of fields to export * @return string SQL String. Example "select s.rowid as r_rowid, s.status as s_status from ..." */ - function build_sql($indice,$array_selected) + function build_sql($indice, $array_selected, $array_filterValue, $array_filtered) { // Build the sql request $sql=$this->array_export_sql_start[$indice]; @@ -215,9 +222,225 @@ class Export } $sql.=$this->array_export_sql_end[$indice]; + //construction du filtrage si le parametrage existe + if (is_array($array_filtered)) + { + $sqlWhere=''; + // pour ne pas a gerer le nombre de condition + foreach ($array_filtered as $key => $value) + { + if ($array_filterValue[$key]) + { + $sqlWhere.=" and ".$this->build_filterQuery($this->array_export_TypeFields[0][$key], $key, $array_filterValue[$key]); + } + } + $sql.=$sqlWhere; + } + return $sql; } + /** + * Build the conditionnal string from filter the query + * + * @param string $TypeField Type of Field to filter + * @param string $NameField Name of the field to filter + * @param string $ValueField Initial value of the field to filter + * @return string sql string of then field ex : "field='xxx'>" + */ + function build_filterQuery($TypeField, $NameField, $ValueField) + { + //print $TypeField." ".$NameField." ".$ValueField; + $InfoFieldList = explode(":", $TypeField); + // build the input field on depend of the type of file + switch ($InfoFieldList[0]) { + case 'Text': + if (strpos($ValueField, "%") > 0) + $szFilterQuery=" ".$NameField." like '".$ValueField."'"; + else + $szFilterQuery=" ".$NameField."='".$ValueField."'"; + break; + case 'Date': + if (strpos($ValueField, "+") > 0) + { + // mode plage + $ValueArray = explode("+", $ValueField); + $szFilterQuery= $this->conditionDate($NameField,$ValueArray[0],">="); + $szFilterQuery.=" and ".$this->conditionDate($NameField,$ValueArray[1],"<="); + } + else + { + if (is_numeric(substr($ValueField,0,1))) + $szFilterQuery=$this->conditionDate($NameField,$ValueField,"="); + else + $szFilterQuery=$this->conditionDate($NameField,substr($ValueField,1),substr($ValueField,0,1)); + } + break; + case 'Duree': + break; + case 'Numeric': + // si le signe - + if (strpos($ValueField, "+") > 0) + { + // mode plage + $ValueArray = explode("+", $ValueField); + $szFilterQuery=$NameField.">=".$ValueArray[0]; + $szFilterQuery.=" and ".$NameField."<=".$ValueArray[1]; + } + else + { + if (is_numeric(substr($ValueField,0,1))) + $szFilterQuery=" ".$NameField."=".$ValueField; + else + $szFilterQuery=" ".$NameField.substr($ValueField,0,1).substr($ValueField,1); + } + break; + case 'Status': + case 'Boolean': + case 'List': + if (is_numeric($ValueField)) + $szFilterQuery=" ".$NameField."=".$ValueField; + else + $szFilterQuery=" ".$NameField."='".$ValueField."'"; + break; + } + + return $szFilterQuery; + } + + /** + * + * @param unknown $Field + * @param unknown $Value + * @param unknown $Sens + * @return string + */ + function conditionDate($Field, $Value, $Sens) + { + if (strlen($Value)==4) $Condition=" date_format(".$Field.",'%Y') ".$Sens." ".$Value; + elseif (strlen($Value)==6) $Condition=" date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'"; + else $Condition=" date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value; + return $Condition; + } + + /** + * Build an input field used to filter the query + * + * @param string $TypeField Type of Field to filter + * @param string $NameField Name of the field to filter + * @param string $ValueField Initial value of the field to filter + * @return string html string of the input field ex : "" + */ + function build_filterField($TypeField, $NameField, $ValueField) + { + $szFilterField=''; + $InfoFieldList = explode(":", $TypeField); + // build the input field on depend of the type of file + switch ($InfoFieldList[0]) { + case 'Text': + case 'Date': + case 'Duree': + case 'Numeric': + $szFilterField=""; + break; + case 'Boolean': + $szFilterField="'; + $szFilterField.=''; + $num = $this->db->num_rows($resql); + + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $labeltoshow=dol_trunc($obj->$InfoFieldList[2],18); + if (!empty($ValueField) && $ValueField == $obj->rowid) + { + $szFilterField.=''; + } + else + { + $szFilterField.=''; + } + $i++; + } + } + $szFilterField.=""; + } + break; + } + + return $szFilterField; + } + + /** + * Build an input field used to filter the query + * + * @param string $TypeField Type of Field to filter + * @return string html string of the input field ex : "" + * TODO replace by translation + */ + function genDocFilter($TypeField) + { + $szMsg=''; + $InfoFieldList = explode(":", $TypeField); + // build the input field on depend of the type of file + switch ($InfoFieldList[0]) { + case 'Text': + $szMsg="% permet de remplacer un ou plusieurs caractères dans la chaine"; + break; + case 'Date': + $szMsg ="'AAAA' 'AAAAMM' 'AAAAMMJJ' : filtre sur une année/mois/jour
"; + $szMsg.="'AAAA+AAAA' 'AAAAMM+AAAAMM' 'AAAAMMJJ+AAAAMMJJ': filtre sur une plage d'année/mois/jour
"; + $szMsg.="'>AAAA' '>AAAAMM' '>AAAAMMJJ' filtre sur les année/mois/jour suivants
"; + $szMsg.="'‹AAAA' '‹AAAAMM' '‹AAAAMMJJ' filtre sur les année/mois/jour précédent
"; + break; + case 'Duree': + break; + case 'Numeric': + $szMsg ="'NNNNN' filtre sur une valeur
"; + $szMsg.="'NNNNN+NNNNN' filtre sur une plage de valeur
"; + $szMsg.="'‹NNNNN' filtre sur les valeurs inférieurs
"; + $szMsg.="'>NNNNN' filtre sur les valeurs supérieurs
"; + break; + case 'Boolean': + break; + case 'List': + break; + } + return $szMsg; + } + /** * Build export file. * File is built into directory $conf->export->dir_temp.'/'.$user->id @@ -230,14 +453,14 @@ class Export * @param string $sqlquery If set, transmit a sql query instead of building it from arrays * @return int <0 if KO, >0 if OK */ - function build_file($user, $model, $datatoexport, $array_selected, $sqlquery = '') + function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $array_filtered, $sqlquery = '') { global $conf,$langs; $indice=0; asort($array_selected); - dol_syslog("Export::build_file $model, $datatoexport, $array_selected"); + dol_syslog("Export::build_file ".$model.", ".$datatoexport.", ".implode(",", $array_selected)); // Check parameters or context properties if (! is_array($this->array_export_fields[$indice])) @@ -254,7 +477,7 @@ class Export $objmodel = new $classname($this->db); if ($sqlquery) $sql = $sqlquery; - else $sql=$this->build_sql($indice,$array_selected); + else $sql=$this->build_sql($indice, $array_selected, $array_filterValue, $array_filtered); // Run the sql $this->sqlusedforexport=$sql; @@ -281,6 +504,8 @@ class Export // Genere ligne de titre $objmodel->write_title($this->array_export_fields[$indice],$array_selected,$outputlangs); + $var=true; + while ($objp = $this->db->fetch_object($resql)) { $var=!$var; @@ -349,9 +574,22 @@ class Export $this->db->begin(); + $filter=''; + if (! empty($this->hexafilter) && ! empty($this->hexafiltervalue)) { + $filter = json_encode(array('field' => $this->hexafilter, 'value' => $this->hexafiltervalue)); + } + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'export_model ('; - $sql.= 'label, type, field)'; - $sql.= " VALUES ('".$this->model_name."', '".$this->datatoexport."', '".$this->hexa."')"; + $sql.= 'label,'; + $sql.= 'type,'; + $sql.= 'field,'; + $sql.= 'filter'; + $sql.= ') VALUES ('; + $sql.= "'".$this->db->escape($this->model_name)."',"; + $sql.= "'".$this->datatoexport."',"; + $sql.= "'".$this->hexa."',"; + $sql.= (! empty($filter)?"'".$filter."'":"null"); + $sql.= ")"; dol_syslog("Export::create sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); @@ -378,7 +616,7 @@ class Export */ function fetch($id) { - $sql = 'SELECT em.rowid, em.field, em.label, em.type'; + $sql = 'SELECT em.rowid, em.field, em.label, em.type, em.filter'; $sql.= ' FROM '.MAIN_DB_PREFIX.'export_model as em'; $sql.= ' WHERE em.rowid = '.$id; @@ -389,16 +627,20 @@ class Export $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; - $this->hexa = $obj->field; - $this->model_name = $obj->label; - $this->datatoexport = $obj->type; + $this->id = $obj->rowid; + $this->hexa = $obj->field; + $this->model_name = $obj->label; + $this->datatoexport = $obj->type; + + $filter = json_decode($obj->filter, true); + $this->hexafilter = (isset($filter['field'])?$filter['field']:''); + $this->hexafiltervalue = (isset($filter['value'])?$filter['value']:''); return 1; } else { - $this->error="Model not found"; + $this->error="ModelNotFound"; return -2; } } @@ -465,6 +707,58 @@ class Export } } + /** + * + */ + function list_export_model() + { + global $conf, $langs; + + $sql = "SELECT em.rowid, em.field, em.label, em.type, em.filter"; + $sql.= " FROM ".MAIN_DB_PREFIX."export_model"; + $sql.= " ORDER BY rowid"; + + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + $keyModel = array_search($obj->type, $this->array_export_code); + print "
rowid.'&datatoexport='.$obj->type.'>'.$obj->label.''; + print img_object($this->array_export_module[$keyModel]->getName(),$this->array_export_icon[$keyModel]).' '; + print $this->array_export_module[$keyModel]->getName().' - '; + // recuperation du nom de l'export + + $string=$langs->trans($this->array_export_label[$keyModel]); + print ($string!=$this->array_export_label[$keyModel]?$string:$this->array_export_label[$keyModel]); + print ''.$obj->type.$keyModel.''.str_replace(',',' , ',$obj->field).''.str_replace(',',' , ',$filter['field']).''.str_replace(',',' , ',$filter['value']).''; + print 'rowid.'">'; + print img_delete(); + print ''; + print "
'; // If value of entityicon=entitylang='icon:Label' @@ -479,7 +579,7 @@ if ($step == 2 && $datatoexport) $tablename=getablenamefromfield($code,$sqlmaxforexport); $htmltext =''.$langs->trans("Name").": ".$text.'
'; $htmltext.=''.$langs->trans("Table")." -> ".$langs->trans("Field").": ".$tablename." -> ".preg_replace('/^.*\./','',$code)."
"; - if ((isset($array_selected[$code]) && $array_selected[$code]) || $modelchoice == 1) + if (isset($array_selected[$code]) && $array_selected[$code]) { // Selected fields print '
 '.img_right().' 
'; @@ -522,7 +622,15 @@ if ($step == 2 && $datatoexport) if (count($array_selected)) { - print ''.$langs->trans("NextStep").''; + // If filters exist + if ($conf->global->MAIN_FEATURES_LEVEL > 1 && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) + { + print ''.$langs->trans("NextStep").''; + } + else + { + print ''.$langs->trans("NextStep").''; + } } else { @@ -534,6 +642,179 @@ if ($step == 2 && $datatoexport) } if ($step == 3 && $datatoexport) +{ + llxHeader('',$langs->trans("NewExport"),'EN:Module_Exports_En|FR:Module_Exports|ES:Módulo_Exportaciones'); + + /* + * Affichage onglets + */ + $h = 0; + + $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=1'; + $head[$h][1] = $langs->trans("Step")." 1"; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=2&datatoexport='.$datatoexport; + $head[$h][1] = $langs->trans("Step")." 2"; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport; + $head[$h][1] = $langs->trans("Step")." 3"; + $hselected=$h; + $h++; + + dol_fiche_head($head, $hselected, $langs->trans("NewExport")); + + print ''; + + // Module + print ''; + print ''; + + // Lot de donnees a exporter + print ''; + print ''; + + // Nbre champs exportes + print ''; + $list=''; + foreach($array_selected as $code=>$value) + { + $list.=(! empty($list)?', ':''); + $list.=(isset($objexport->array_export_fields[0][$code])?$langs->trans($objexport->array_export_fields[0][$code]):''); + } + print ''; + + print '
'.$langs->trans("Module").''; + //print img_object($objexport->array_export_module[0]->getName(),$objexport->array_export_module[0]->picto).' '; + print $objexport->array_export_module[0]->getName(); + print '
'.$langs->trans("DatasetToExport").''; + $icon=$objexport->array_export_icon[0]; + $label=$objexport->array_export_label[0]; + //print $value.'-'.$icon.'-'.$label."
"; + print img_object($objexport->array_export_module[0]->getName(),$icon).' '; + print $label; + print '
'.$langs->trans("ExportedFields").''.$list.'
'; + print '
'; + + // Combo list of export models + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("SelectExportFields").' '; + $htmlother->select_export_model($exportmodelid,'exportmodelid',$datatoexport,1); + print ''; + print '
'; + print '
'; + + // un formulaire en plus pour recuperer les filtres + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Champs exportables + $fieldsarray=$objexport->array_export_fields[0]; + // Champs filtrable + $Typefieldsarray=$objexport->array_export_TypeFields[0]; + // valeur des filtres + $ValueFiltersarray=(! empty($objexport->array_export_FilterValue[0])?$objexport->array_export_FilterValue[0]:''); + // Select request if all fields are selected + $sqlmaxforexport=$objexport->build_sql(0, array(), array(), array()); + + $var=true; + $i = 0; + // on boucle sur les champs filtrable + foreach($Typefieldsarray as $code=>$label) + { + $var=!$var; + print ""; + + $i++; + + $entity=(! empty($objexport->array_export_entities[0][$code])?$objexport->array_export_entities[0][$code]:$objexport->array_export_icon[0]); + $entityicon=(! empty($entitytoicon[$entity])?$entitytoicon[$entity]:$entity); + $entitylang=(! empty($entitytolang[$entity])?$entitytolang[$entity]:$entity); + + print ''; + + $labelName=(! empty($fieldsarray[$code])?$fieldsarray[$code]:''); + $ValueFilter=(! empty($array_filtervalue[$code])?$array_filtervalue[$code]:''); + $text=$langs->trans($labelName); + + $tablename=getablenamefromfield($code,$sqlmaxforexport); + $htmltext =''.$langs->trans("Name").': '.$text.' ('.$label.')
'; + $htmltext.=''.$langs->trans("Table")." -> ".$langs->trans("Field").": ".$tablename." -> ".preg_replace('/^.*\./','',$code)."
"; + if (isset($array_filtered[$code]) && $array_filtered[$code]) + { + // Selected fields + print ''; + print ''; + print ''; + //$bit=1; FIXME not used? + // ici le filtre + print ''; + } + else + { + // Fields not selected + print ''; + print ''; + print ''; + //$bit=0; FIXME not used? + } + + print ''; + //$save_selectFilter.=$bit; FIXME not used? + } + + print '
'.$langs->trans("Entities").''.$langs->trans("FilterableFields").''.$langs->trans("FilteredFields").''.$langs->trans("FilteredFieldsValues").'
'; + // If value of entityicon=entitylang='icon:Label' + $tmparray=explode(':',$entityicon); + if (count($tmparray) >=2) + { + $entityicon=$tmparray[0]; + $entitylang=$tmparray[1]; + } + print img_object('',$entityicon).' '.$langs->trans($entitylang); + print ' '.img_left().''; + print $form->textwithpicto($text,$htmltext); + print ''; + $szInfoFiltre=$objexport->genDocFilter($label); + if ($szInfoFiltre) + print $form->textwithpicto($objexport->build_filterField($label, $labelName, $ValueFilter), $szInfoFiltre); + else + print $objexport->build_filterField($label, $labelName, $ValueFilter); + print ''; + //print $text.'-'.$htmltext."
"; + print $form->textwithpicto($text,$htmltext); + //print ' ('.$code.')'; + print '
'.img_right().' 
'; + + print ''; + + if ($mesg) print $mesg; + + /* + * Barre d'action + * + */ + print '
'; + // il n'est pas obligatoire de filtrer les champs + print ''.$langs->trans("NextStep").''; + print '
'; + +} + +if ($step == 4 && $datatoexport) { asort($array_selected); @@ -552,8 +833,16 @@ if ($step == 3 && $datatoexport) $head[$h][1] = $langs->trans("Step")." 2"; $h++; - $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport; - $head[$h][1] = $langs->trans("Step")." 3"; + // If filters exist + if ($conf->global->MAIN_FEATURES_LEVEL > 1 && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) + { + $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport; + $head[$h][1] = $langs->trans("Step")." 3"; + $h++; + } + + $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=4&datatoexport='.$datatoexport; + $head[$h][1] = $langs->trans("Step")." 4"; $hselected=$h; $h++; @@ -585,11 +874,24 @@ if ($step == 3 && $datatoexport) } print '
'.$list.'
'.$langs->trans("FilteredFields").''.$list.'
'; print '
'; // Select request if all fields are selected - $sqlmaxforexport=$objexport->build_sql(0,array()); + $sqlmaxforexport=$objexport->build_sql(0, array(), array(), array()); print $langs->trans("ChooseFieldsOrdersAndTitle").'
'; @@ -609,8 +911,8 @@ if ($step == 3 && $datatoexport) print ""; $entity=(! empty($objexport->array_export_entities[0][$code])?$objexport->array_export_entities[0][$code]:$objexport->array_export_icon[0]); - $entityicon=$entitytoicon[$entity]?$entitytoicon[$entity]:$entity; - $entitylang=$entitytolang[$entity]?$entitytolang[$entity]:$entity; + $entityicon=(! empty($entitytoicon[$entity])?$entitytoicon[$entity]:$entity); + $entitylang=(! empty($entitytolang[$entity])?$entitytolang[$entity]:$entity); print ''; // If value of entityicon=entitylang='icon:Label' @@ -635,8 +937,8 @@ if ($step == 3 && $datatoexport) print ''; print $value.' '; print ''; - if ($value < count($array_selected)) print ''.img_down().''; - if ($value > 1) print ''.img_up().''; + if ($value < count($array_selected)) print ''.img_down().''; + if ($value > 1) print ''.img_up().''; print ''; //print ' '; @@ -660,7 +962,7 @@ if ($step == 3 && $datatoexport) if (count($array_selected)) { - print ''.$langs->trans("NextStep").''; + print ''.$langs->trans("NextStep").''; } print ''; @@ -725,7 +1027,7 @@ if ($step == 3 && $datatoexport) } -if ($step == 4 && $datatoexport) +if ($step == 5 && $datatoexport) { asort($array_selected); @@ -744,12 +1046,20 @@ if ($step == 4 && $datatoexport) $head[$h][1] = $langs->trans("Step")." 2"; $h++; + // si le filtrage est parametre pour l'export ou pas + if ($conf->global->MAIN_FEATURES_LEVEL > 1 && isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0])) + { + $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport; + $head[$h][1] = $langs->trans("Step")." 3"; + $h++; + } + $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=3&datatoexport='.$datatoexport; - $head[$h][1] = $langs->trans("Step")." 3"; + $head[$h][1] = $langs->trans("Step")." 4"; $h++; - $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=4&datatoexport='.$datatoexport; - $head[$h][1] = $langs->trans("Step")." 4"; + $head[$h][0] = DOL_URL_ROOT.'/exports/export.php?step=5&datatoexport='.$datatoexport; + $head[$h][1] = $langs->trans("Step")." 5"; $hselected=$h; $h++; @@ -781,6 +1091,19 @@ if ($step == 4 && $datatoexport) } print ''.$list.''; + // Nbre champs filtres + if (is_array($objexport->array_export_TypeFields[0])) + { + print ''.$langs->trans("FilteredFields").''; + $list=''; + foreach($array_filtered as $code=>$value) + { + $list.=($list?', ':''); + $list.="[".$langs->trans($objexport->array_export_fields[0][$code])."]='".$array_filtervalue[$code]."'"; + } + print ''.$list.''; + } + print ''; print '
'; @@ -830,7 +1153,7 @@ if ($step == 4 && $datatoexport) // Affiche liste des documents // NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste - $formfile->show_documents('export','',$conf->export->dir_temp.'/'.$user->id,$_SERVER["PHP_SELF"].'?step=4&datatoexport='.$datatoexport,$liste,1,(! empty($_POST['model'])?$_POST['model']:'csv'),1,1); + $formfile->show_documents('export','',$conf->export->dir_temp.'/'.$user->id,$_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport,$liste,1,(! empty($_POST['model'])?$_POST['model']:'csv'),1,1); print ' '; print ''; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 937e2156561..26203b23027 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -307,7 +307,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) } $ret=$object->fetch($id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } unset($_POST['qty']); unset($_POST['type']); @@ -369,7 +369,7 @@ else if ($action == 'updateligne' && $user->rights->fournisseur->commande->creer if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } } else @@ -395,7 +395,7 @@ else if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->r if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } } else @@ -429,7 +429,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fourn if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } } else @@ -582,7 +582,7 @@ else if ($action == 'up' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid'])); exit; } @@ -597,7 +597,7 @@ else if ($action == 'down' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid'])); exit; } @@ -621,7 +621,7 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) / $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - $result=supplier_order_pdf_create($db, $object,$object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref); + $result=supplier_order_pdf_create($db, $object,$object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 9aca380a9fa..4d58652bf27 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1,2056 +1,2056 @@ - - * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2004 Christophe Combelles - * Copyright (C) 2005 Marc Barilley - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2012 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/fourn/facture/fiche.php - * \ingroup facture, fournisseur - * \brief Page for supplier invoice card (view, edit, validate) - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - - -$langs->load('bills'); -$langs->load('suppliers'); -$langs->load('companies'); - -$mesg=''; -$errors=array(); -$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); -$action = GETPOST("action"); -$confirm = GETPOST("confirm"); - -//PDF -$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); - -// Security check -$socid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; -$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); - -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); -$hookmanager->initHooks(array('invoicesuppliercard')); - -$object=new FactureFournisseur($db); - - - -/* - * Actions -*/ - -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') -{ - if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) - { - $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; - } - else - { - $result=$object->createFromClone($id); - if ($result > 0) - { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); - exit; - } - else - { - $langs->load("errors"); - $mesg='
'.$langs->trans($object->error).'
'; - $action=''; - } - } -} - -elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider) -{ - $idwarehouse=GETPOST('idwarehouse'); - - $object->fetch($id); - $object->fetch_thirdparty(); - - // Check parameters - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $object->hasProductsOrServices(1)) - { - $langs->load("stocks"); - if (! $idwarehouse || $idwarehouse == -1) - { - $error++; - $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); - $action=''; - } - } - - if (! $error) - { - $result = $object->validate($user,'',$idwarehouse); - if ($result < 0) - { - $mesg='
'.$object->error.'
'; - } - } -} - -elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer) -{ - $object->fetch($id); - $object->fetch_thirdparty(); - $result=$object->delete($id); - if ($result > 0) - { - header('Location: index.php'); - exit; - } - else - { - $mesg='
'.$object->error.'
'; - } -} - -elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $ret = $object->deleteline(GETPOST('lineid')); - if ($ret > 0) - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } - else - { - $mesg='
'.$object->error.'
'; - } -} - -elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $result=$object->set_paid($user); -} - -// Set supplier ref -elseif ($action == 'setfacnumber' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $result=$object->set_ref_supplier($user, GETPOST('facnumber')); -} - -// Set label -elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $object->label=$_POST['label']; - $result=$object->update($user); - if ($result < 0) dol_print_error($db); -} - -elseif ($action == 'setdatef' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $object->date=dol_mktime(12,0,0,$_POST['datefmonth'],$_POST['datefday'],$_POST['datefyear']); - if ($object->date_echeance < $object->date) $object->date_echeance=$object->date; - $result=$object->update($user); - if ($result < 0) dol_print_error($db,$object->error); -} -elseif ($action == 'setdate_lim_reglement' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $object->date_echeance=dol_mktime(12,0,0,$_POST['date_lim_reglementmonth'],$_POST['date_lim_reglementday'],$_POST['date_lim_reglementyear']); + + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004 Christophe Combelles + * Copyright (C) 2005 Marc Barilley + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2012 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/fourn/facture/fiche.php + * \ingroup facture, fournisseur + * \brief Page for supplier invoice card (view, edit, validate) + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + + +$langs->load('bills'); +$langs->load('suppliers'); +$langs->load('companies'); + +$mesg=''; +$errors=array(); +$id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); +$action = GETPOST("action"); +$confirm = GETPOST("confirm"); + +//PDF +$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); + +// Security check +$socid=''; +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager=new HookManager($db); +$hookmanager->initHooks(array('invoicesuppliercard')); + +$object=new FactureFournisseur($db); + + + +/* + * Actions +*/ + +// Action clone object +if ($action == 'confirm_clone' && $confirm == 'yes') +{ + if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) + { + $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; + } + else + { + $result=$object->createFromClone($id); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + $langs->load("errors"); + $mesg='
'.$langs->trans($object->error).'
'; + $action=''; + } + } +} + +elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider) +{ + $idwarehouse=GETPOST('idwarehouse'); + + $object->fetch($id); + $object->fetch_thirdparty(); + + // Check parameters + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $object->hasProductsOrServices(1)) + { + $langs->load("stocks"); + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); + $action=''; + } + } + + if (! $error) + { + $result = $object->validate($user,'',$idwarehouse); + if ($result < 0) + { + $mesg='
'.$object->error.'
'; + } + } +} + +elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer) +{ + $object->fetch($id); + $object->fetch_thirdparty(); + $result=$object->delete($id); + if ($result > 0) + { + header('Location: index.php'); + exit; + } + else + { + $mesg='
'.$object->error.'
'; + } +} + +elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($id); + $ret = $object->deleteline(GETPOST('lineid')); + if ($ret > 0) + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; + } + else + { + $mesg='
'.$object->error.'
'; + } +} + +elseif ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($id); + $result=$object->set_paid($user); +} + +// Set supplier ref +elseif ($action == 'setfacnumber' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($id); + $result=$object->set_ref_supplier($user, GETPOST('facnumber')); +} + +// Set label +elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($id); + $object->label=$_POST['label']; + $result=$object->update($user); + if ($result < 0) dol_print_error($db); +} + +elseif ($action == 'setdatef' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($id); + $object->date=dol_mktime(12,0,0,$_POST['datefmonth'],$_POST['datefday'],$_POST['datefyear']); + if ($object->date_echeance < $object->date) $object->date_echeance=$object->date; + $result=$object->update($user); + if ($result < 0) dol_print_error($db,$object->error); +} +elseif ($action == 'setdate_lim_reglement' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($id); + $object->date_echeance=dol_mktime(12,0,0,$_POST['date_lim_reglementmonth'],$_POST['date_lim_reglementday'],$_POST['date_lim_reglementyear']); if ($object->date_echeance < $object->date) { $object->date_echeance=$object->date; setEventMessage($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"),'warnings'); } - $result=$object->update($user); - if ($result < 0) dol_print_error($db,$object->error); -} -elseif ($action == 'setnote_public' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} -elseif ($action == 'setnote' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} - -// Delete payment -elseif ($action == 'deletepaiement') -{ - $object->fetch($id); - if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) - { - $paiementfourn = new PaiementFourn($db); - $paiementfourn->fetch(GETPOST('paiement_id')); - $result=$paiementfourn->delete(); - if ($result < 0) $mesg='
'.$paiementfourn->error.'
'; - } -} - -// Create -elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) -{ - $error=0; - - $datefacture=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); - - if ($datefacture == '') - { - $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')).'
'; - $action='create'; - $_GET['socid']=$_POST['socid']; - $error++; - } - if (! GETPOST('facnumber')) - { - $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')).'
'; - $action='create'; - $_GET['socid']=$_POST['socid']; - $error++; - } - - if (! $error) - { - $db->begin(); - - // Creation facture - $object->ref = $_POST['facnumber']; - $object->socid = $_POST['socid']; - $object->libelle = $_POST['libelle']; - $object->date = $datefacture; - $object->date_echeance = $datedue; - $object->note_public = $_POST['note']; - - // If creation from another object of another module - if ($_POST['origin'] && $_POST['originid']) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = $_POST['origin']; - /*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) - { - $element = $regs[1]; - $subelement = $regs[2]; - }*/ - - // For compatibility - if ($element == 'order') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - $element = 'comm/propal'; $subelement = 'propal'; - } - if ($element == 'contract') { - $element = $subelement = 'contrat'; - } - if ($element == 'order_supplier') { - $element = 'fourn'; $subelement = 'fournisseur.commande'; - } - - $object->origin = $_POST['origin']; - $object->origin_id = $_POST['originid']; - - $id = $object->create($user); - - // Add lines - if ($id > 0) - { - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; - $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; - $srcobject = new $classname($db); - - $result=$srcobject->fetch($_POST['originid']); - if ($result > 0) - { - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); - - $num=count($lines); - for ($i = 0; $i < $num; $i++) - { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); - - // Dates - // TODO mutualiser - $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - - $result = $object->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->qty, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - 'HT', - $product_type - ); - - if ($result < 0) - { - $error++; - break; - } - } - } - else - { - $error++; - } - } - else - { - $error++; - } - } - // If some invoice's lines already known - else - { - $id = $object->create($user); - if ($id < 0) - { - $error++; - } - - if (! $error) - { - for ($i = 1 ; $i < 9 ; $i++) - { - $label = $_POST['label'.$i]; - $amountht = price2num($_POST['amount'.$i]); - $amountttc = price2num($_POST['amountttc'.$i]); - $tauxtva = price2num($_POST['tauxtva'.$i]); - $qty = $_POST['qty'.$i]; - $fk_product = $_POST['fk_product'.$i]; - if ($label) - { - if ($amountht) - { - $price_base='HT'; $amount=$amountht; - } - else - { - $price_base='TTC'; $amount=$amountttc; - } - $atleastoneline=1; - - $product=new Product($db); - $product->fetch($_POST['idprod'.$i]); - - $ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base); - if ($ret < 0) $error++; - } - } - } - } - - if ($error) - { - $langs->load("errors"); - $db->rollback(); - $mesg='
'.$langs->trans($object->error).'
'; - $action='create'; - $_GET['socid']=$_POST['socid']; - } - else - { - $db->commit(); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - exit; - } - } -} - -// Modification d'une ligne -elseif ($action == 'update_line') -{ - if (GETPOST('etat') == '1' && ! GETPOST('cancel')) // si on valide la modification - { - $object->fetch($id); - $object->fetch_thirdparty(); - - if ($_POST['puht']) - { - $pu=$_POST['puht']; - $price_base_type='HT'; - } - if ($_POST['puttc']) - { - $pu=$_POST['puttc']; - $price_base_type='TTC'; - } - - if (GETPOST('idprod')) - { - $prod = new Product($db); - $prod->fetch($_POST['idprod']); - $label = $prod->description; - if (trim($_POST['desc']) != trim($label)) $label=$_POST['desc']; - - $type = $prod->type; - } - else - { - - $label = $_POST['desc']; - $type = $_POST["type"]?$_POST["type"]:0; - - } - - $localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty); - $localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty); - $remise_percent=GETPOST('remise_percent'); - - $result=$object->updateline(GETPOST('lineid'), $label, $pu, GETPOST('tauxtva'), $localtax1tx, $localtax2tx, GETPOST('qty'), GETPOST('idprod'), $price_base_type, 0, $type, $remise_percent); - if ($result >= 0) - { - unset($_POST['label']); - } - } -} - -elseif ($action == 'addline') -{ - $ret=$object->fetch($id); - if ($ret < 0) - { - dol_print_error($db,$object->error); - exit; - } - $ret=$object->fetch_thirdparty(); - - if ($_POST['idprodfournprice']) // > 0 or -1 - { - $product=new Product($db); - $idprod=$product->get_buyprice($_POST['idprodfournprice'], $_POST['qty']); // Just to see if a price exists for the quantity. Not used to found vat - - if ($idprod > 0) - { - $result=$product->fetch($idprod); - - // cas special pour lequel on a les meme reference que le fournisseur - // $label = '['.$product->ref.'] - '. $product->libelle; - $label = $product->description; - $label.= $product->description && $_POST['np_desc'] ? "\n" : ""; - $label.= $_POST['np_desc']; - - $tvatx=get_default_tva($object->thirdparty, $mysoc, $product->id, $_POST['idprodfournprice']); - - $localtax1tx= get_localtax($tvatx, 1, $object->thirdparty); - $localtax2tx= get_localtax($tvatx, 2, $object->thirdparty); - $remise_percent=GETPOST('remise_percent'); - $type = $product->type; - - $result=$object->addline($label, $product->fourn_pu, $tvatx, $localtax1tx, $localtax2tx, $_POST['qty'], $idprod, $remise_percent); - - } - if ($idprod == -1) - { - // Quantity too low - $langs->load("errors"); - $mesg='
'.$langs->trans("ErrorQtyTooLowForThisSupplier").'
'; - } - } - else - { - $tauxtva = price2num($_POST['tauxtva']); - $localtax1tx= get_localtax($tauxtva, 1, $object->thirdparty); - $localtax2tx= get_localtax($tauxtva, 2, $object->thirdparty); - $remise_percent=GETPOST('remise_percent'); - - if (! $_POST['dp_desc']) - { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Description")).'
'; - } - else - { - $type = $_POST["type"]; - if (! empty($_POST['amount'])) - { - $ht = price2num($_POST['amount']); - $price_base_type = 'HT'; - - //$desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0) - $result=$object->addline($_POST['dp_desc'], $ht, $tauxtva, $localtax1tx, $localtax2tx, $_POST['qty'], 0, $remise_percent, $datestart, $dateend, 0, 0, $price_base_type, $type); - } - else - { - $ttc = price2num($_POST['amountttc']); - $ht = $ttc / (1 + ($tauxtva / 100)); - $price_base_type = 'HT'; - $result=$object->addline($_POST['dp_desc'], $ht, $tauxtva,$localtax1tx, $localtax2tx, $_POST['qty'], 0, $remise_percent, $datestart, $dateend, 0, 0, $price_base_type, $type); - } - } - } - - //print "xx".$tva_tx; exit; - if ($result > 0) - { - // Define output language - $outputlangs = $langs; - $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs); - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['idprodfournprice']); - unset($_POST['remise_percent']); - unset($_POST['dp_desc']); - unset($_POST['np_desc']); - unset($_POST['pu']); - unset($_POST['tva_tx']); - unset($_POST['label']); - unset($localtax1_tx); - unset($localtax2_tx); - } - else if (empty($mesg)) - { - $mesg='
'.$object->error.'
'; - } - - $action = ''; -} - -elseif ($action == 'classin') -{ - $object->fetch($id); - $result=$object->setProject($_POST['projectid']); -} - - -// Set invoice to draft status -elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer) -{ - $object->fetch($id); - - $totalpaye = $object->getSommePaiement(); - $resteapayer = $object->total_ttc - $totalpaye; - - // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees - //$ventilExportCompta = $object->getVentilExportCompta(); - - // On verifie si aucun paiement n'a ete effectue - if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) - { - $object->set_draft($user); - - $outputlangs = $langs; - if (! empty($_REQUEST['lang_id'])) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs); - } -} - -// Set invoice to validated/unpaid status -elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer) -{ - $result = $object->fetch($id); - if ($object->statut == 2 - || ($object->statut == 3 && $object->close_code != 'replaced')) - { - $result = $object->set_unpaid($user); - if ($result > 0) - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } - else - { - $mesg='
'.$object->error.'
'; - } - } -} - -// Add file in email form -if (GETPOST('addfile')) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - dol_add_file_process($upload_dir_tmp,0,0); - $action='presend'; -} - -// Remove file in email form -if (! empty($_POST['removedfile'])) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process($_POST['removedfile'],0); - $action='presend'; -} - -// Send mail -if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) -{ - $langs->load('mails'); - - $object->fetch($id); - $result=$object->fetch_thirdparty(); - if ($result > 0) - { -// $ref = dol_sanitizeFileName($object->ref); -// $file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref.'/'.$ref.'.pdf'; - -// if (is_readable($file)) -// { - if ($_POST['sendto']) - { - // Le destinataire a ete fourni via le champ libre - $sendto = $_POST['sendto']; - $sendtoid = 0; - } - elseif ($_POST['receiver'] != '-1') - { - // Recipient was provided from combo list - if ($_POST['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); - $sendtoid = $_POST['receiver']; - } - } - - if (dol_strlen($sendto)) - { - $langs->load("commercial"); - - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; - $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; - $message = $_POST['message']; - $sendtocc = $_POST['sendtocc']; - $deliveryreceipt = $_POST['deliveryreceipt']; - - if ($action == 'send') - { - if (dol_strlen($_POST['subject'])) $subject=$_POST['subject']; - else $subject = $langs->transnoentities('CustomerOrder').' '.$object->ref; - $actiontypecode='AC_SUP_ORD'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; - if ($message) - { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; - } - $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } - - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $attachedfiles=$formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - // Send mail - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); - if ($mailfile->error) - { - $mesg='
'.$mailfile->error.'
'; - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " - - $error=0; - - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2 = $actionmsg2; - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('BILL_SUPPLIER_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers - - if ($error) - { - dol_print_error($db); - } - else - { - // Redirect here - // This avoid sending mail twice if going out and then back to page - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mesg='.urlencode($mesg)); - exit; - } - } - else - { - $langs->load("other"); - $mesg='
'; - if ($mailfile->error) - { - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $mesg.='
'.$mailfile->error; - } - else - { - $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - $mesg.='
'; - } - } - } - - else - { - $langs->load("other"); - $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; - dol_syslog('Recipient email is empty'); - } -/* } - else - { - $langs->load("errors"); - $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; - dol_syslog('Failed to read file: '.$file); - }*/ - } - else - { - $langs->load("other"); - $mesg='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'
'; - dol_syslog('Unable to read data from the invoice. The invoice file has perhaps not been generated.'); - } - - //$action = 'presend'; -} - -// Build document -elseif ($action == 'builddoc') -{ - // Save modele used - $object->fetch($id); - $object->fetch_thirdparty(); - if ($_REQUEST['model']) - { - $object->setDocModel($user, $_REQUEST['model']); - } - - $outputlangs = $langs; - if (! empty($_REQUEST['lang_id'])) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - $result=supplier_invoice_pdf_create($db,$object,$object->modelpdf,$outputlangs); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - else - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); - exit; - } -} - -// Delete file in doc form -elseif ($action == 'remove_file') -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - if ($object->fetch($id)) - { - $object->fetch_thirdparty(); - $upload_dir = $conf->fournisseur->facture->dir_output . "/"; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - } -} - -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer) -{ - if ($action == 'addcontact') - { - $result = $object->fetch($id); - - if ($result > 0 && $id > 0) - { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; - } - else - { - $mesg = '
'.$object->error.'
'; - } - } - } - - // bascule du statut d'un contact - else if ($action == 'swapstatut') - { - if ($object->fetch($id)) - { - $result=$object->swapContactStatus(GETPOST('ligne')); - } - else - { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact') - { - $object->fetch($id); - $result = $object->delete_contact($_GET["lineid"]); - - if ($result >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else { - dol_print_error($db); - } - } -} - - -/* - * View - */ - -$form = new Form($db); -$formfile = new FormFile($db); -$bankaccountstatic=new Account($db); - -llxHeader('','',''); - -// Mode creation -if ($action == 'create') -{ - print_fiche_titre($langs->trans('NewBill')); - - dol_htmloutput_mesg($mesg); - - $societe=''; - if ($_GET['socid']) - { - $societe=new Societe($db); - $societe->fetch($_GET['socid']); - } - - if (GETPOST('origin') && GETPOST('originid')) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = GETPOST('origin'); - - if ($element == 'project') - { - $projectid=GETPOST('originid'); - } - else if (in_array($element,array('order_supplier'))) - { - // For compatibility - if ($element == 'order') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - dol_htmloutput_errors('',$errors); - $element = 'comm/propal'; $subelement = 'propal'; - } - if ($element == 'contract') { - $element = $subelement = 'contrat'; - } - if ($element == 'order_supplier') { - $element = 'fourn'; $subelement = 'fournisseur.commande'; - } - - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; - $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; - $objectsrc = new $classname($db); - $objectsrc->fetch(GETPOST('originid')); - $objectsrc->fetch_thirdparty(); - - $projectid = (!empty($objectsrc->fk_project)?$object->fk_project:''); - //$ref_client = (!empty($objectsrc->ref_client)?$object->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)); - $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; - - $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); - $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); - } - } - else - { - $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); - $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); - } - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Ref - print ''; - - // Third party - print ''; - print ''; - - // Ref supplier - print ''; - print ''; - - print ''; - - // Label - print ''; - - // Date invoice - print ''; - - // Due date - print ''; - - print ''; - print ''; - print ''; - - if (is_object($objectsrc)) - { - print "\n"; - print "\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - - $txt=$langs->trans($classname); - if ($classname=='CommandeFournisseur') $txt=$langs->trans("SupplierOrder"); - print ''; - print ''; - print '"; - if ($mysoc->country_code=='ES') - { - if ($mysoc->localtax1_assuj=="1") //Localtax1 RE - { - print '"; - } - - if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF - { - print '"; - } - } - print '"; - } - else - { - // TODO more bugs - if (1==2 && ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - for ($i = 1 ; $i < 9 ; $i++) - { - $value_qty = '1'; - $value_tauxtva = ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } - } - - // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - - // Bouton "Create Draft" - print "
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Supplier').''; - - if ($_REQUEST['socid'] > 0) - { - print $societe->getNomUrl(1); - print ''; - } - else - { - print $form->select_company((empty($_GET['socid'])?'':$_GET['socid']),'socid','s.fournisseur = 1',1); - } - print '
'.$langs->trans('RefSupplier').'
'.$langs->trans('Type').''; - print ''."\n"; - - // Standard invoice - print ''."\n"; - - /* - // Deposit - print ''."\n"; - - // Proforma - if (! empty($conf->global->FACTURE_USE_PROFORMAT)) - { - print ''."\n"; - } - - // Replacement - print ''; - - // Credit note - print ''."\n"; - */ - print '
'; - print ''; - print ''; - $desc=$form->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); - print $desc; - print '
'; - print ''; - print ''; - $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); - print $desc; - print '
'; - print ''; - print ''; - $desc=$form->textwithpicto($langs->trans("InvoiceProForma"),$langs->transnoentities("InvoiceProFormaDesc"),1); - print $desc; - print '
'; - print ''; - print ''; - $text=$langs->trans("InvoiceReplacementAsk").' '; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); - print $desc; - print '
'; - print ''; - print ''; - $text=$langs->transnoentities("InvoiceAvoirAsk").' '; - // $text.=''; - $text.=''; - $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); - print $desc; - print '
'; - print '
'.$langs->trans('Label').'
'.$langs->trans('DateInvoice').''; - $form->select_date($dateinvoice,'','','','',"add",1,1); - print '
'.$langs->trans('DateMaxPayment').''; - $form->select_date($datedue,'ech','','','',"add",1,1); - print '
'.$langs->trans('NotePublic').'
'.$txt.''.$objectsrc->getNomUrl(1).'
'.$langs->trans('TotalHT').''.price($objectsrc->total_ht).'
'.$langs->trans('TotalVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('TotalTTC').''.price($objectsrc->total_ttc)."
 '.$langs->trans('Label').''.$langs->trans('PriceUHT').''.$langs->trans('VAT').''.$langs->trans('Qty').''.$langs->trans('PriceUTTC').'
'.$i.''; - print $form->load_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc); - print '
\n"; - - print '
'; - - print "\n"; - - - // Show origin lines - if (is_object($objectsrc)) - { - print '
'; - - $title=$langs->trans('ProductsAndServices'); - print_titre($title); - - print ''; - - $objectsrc->printOriginLinesList($hookmanager); - - print '
'; - } -} -else -{ - if ($id > 0) - { - /* *************************************************************************** */ - /* */ - /* Fiche en mode visu ou edition */ - /* */ - /* *************************************************************************** */ - - $now=dol_now(); - - $productstatic = new Product($db); - - $object->fetch($id); - - $societe = new Fournisseur($db); - $societe->fetch($object->socid); - - /* - * View card - */ - $head = facturefourn_prepare_head($object); - $titre=$langs->trans('SupplierInvoice'); - dol_fiche_head($head, 'card', $titre, 0, 'bill'); - - dol_htmloutput_mesg($mesg); - dol_htmloutput_errors('',$errors); - - // Confirmation de la suppression d'une ligne produit - if ($action == 'confirm_delete_line') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 1, 1); - if ($ret == 'html') print '
'; - } - - // Clone confirmation - if ($action == 'clone') - { - // Create an array for form - $formquestion=array( - //'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) - ); - // Paiement incomplet. On demande si motif = escompte ou autre - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$object->ref),'confirm_clone',$formquestion,'yes', 1); - if ($ret == 'html') print '
'; - } - - // Confirmation de la validation - if ($action == 'valid') - { - $formquestion=array(); - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $object->hasProductsOrServices(1)) - { - $langs->load("stocks"); - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); - $formquestion=array( - //'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); - } - - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $object->ref), 'confirm_valid', $formquestion, 1, 1, 240); - if ($ret == 'html') print '
'; - } - - // Confirmation set paid - if ($action == 'paid') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', 0, 1); - if ($ret == 'html') print '
'; - } - - // Confirmation de la suppression de la facture fournisseur - if ($action == 'delete') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1); - if ($ret == 'html') print '
'; - } - - - /** - * Invoice - */ - print ''; - - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - print "\n"; - - // Ref supplier - print ''; - - // Third party - print ''; - print ''; - - // Type - print ''; - - // Label - print ''; - print ''; - - /* - * List of payments - */ - $nbrows=7; $nbcols=2; - if (! empty($conf->projet->enabled)) $nbrows++; - if (! empty($conf->banque->enabled)) $nbcols++; - - // Local taxes - if ($mysoc->country_code=='ES') - { - if($mysoc->localtax1_assuj=="1") $nbrow++; - if($mysoc->localtax2_assuj=="1") $nbrow++; - } - - print ''; - - print ''; - - // Date - print ''; - - // Due date - print ''; - - // Status - $alreadypaid=$object->getSommePaiement(); - print ''; - - print ''; - print ''; - - // Amount Local Taxes - if ($mysoc->country_code=='ES') - { - if ($mysoc->localtax1_assuj=="1") //Localtax1 RE - { - print ''; - print ''; - print ''; - } - if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF - { - print ''; - print ''; - print ''; - } - } - print ''; - - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load('projects'); - print ''; - print ''; - print ''; - } - - // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref'); - print '
'.$form->editfieldkey("RefSupplier",'facnumber',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).''; - print $form->editfieldval("RefSupplier",'facnumber',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)); - print '
'.$langs->trans('Supplier').''.$societe->getNomUrl(1); - print '   ('.$langs->trans('OtherBills').')
'.$langs->trans('Type').''; - print $object->getLibType(); - if ($object->type == 1) - { - $facreplaced=new FactureFournisseur($db); - $facreplaced->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; - } - if ($object->type == 2) - { - $facusing=new FactureFournisseur($db); - $facusing->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')'; - } - - $facidavoir=$object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) - { - print ' ('.$langs->transnoentities("InvoiceHasAvoir"); - $i=0; - foreach($facidavoir as $id) - { - if ($i==0) print ' '; - else print ','; - $facavoir=new FactureFournisseur($db); - $facavoir->fetch($id); - print $facavoir->getNomUrl(1); - } - print ')'; - } - if (isset($facidnext) && $facidnext > 0) - { - $facthatreplace=new FactureFournisseur($db); - $facthatreplace->fetch($facidnext); - print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; - } - print '
'.$form->editfieldkey("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).''.$form->editfieldval("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).''; - - $sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,'; - $sql.= ' c.libelle as paiement_type,'; - $sql.= ' pf.amount,'; - $sql.= ' ba.rowid as baid, ba.ref, ba.label'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; - $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; - $sql.= ' ORDER BY p.datep, p.tms'; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $totalpaye = 0; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print ''; - print ''; - print ''; - - $var=true; - if ($num > 0) - { - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print '\n"; - print ''; - if (! empty($conf->banque->enabled)) - { - $bankaccountstatic->id=$objp->baid; - $bankaccountstatic->ref=$objp->ref; - $bankaccountstatic->label=$objp->ref; - print ''; - } - print ''; - print ''; - print ''; - $totalpaye += $objp->amount; - $i++; - } - } - else - { - print ''; - } - - if ($object->paye == 0) - { - print ''; - print ''; - - $resteapayer = $object->total_ttc - $totalpaye; - - print ''; - print ''; - } - print '
'.$langs->trans('Payments').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
'.img_object($langs->trans('ShowPayment'),'payment').' '.dol_print_date($db->jdate($objp->dp),'day')."'.$objp->paiement_type.' '.$objp->num_paiement.''; - print $bankaccountstatic->getNomUrl(1,'transactions'); - print ''.price($objp->amount).''; - if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) - { - print 'rowid.'">'; - print img_delete(); - print ''; - } - print '
'.$langs->trans("None").'
'.$langs->trans('AlreadyPaid').' :'.price($totalpaye).'
'.$langs->trans("Billed").' :'.price($object->total_ttc).'
'.$langs->trans('RemainderToPay').' :'.price($resteapayer).'
'; - $db->free($result); - } - else - { - dol_print_error($db); - } - print '
'.$form->editfieldkey("Date",'datef',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').''; - print $form->editfieldval("Date",'datef',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker'); - print '
'.$form->editfieldkey("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').''; - print $form->editfieldval("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker'); - if ($action != 'editdate_lim_reglement' && $object->statut < 2 && $object->date_echeance && $object->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_warning($langs->trans('Late')); - print '
'.$langs->trans('Status').''.$object->getLibStatut(4,$alreadypaid).'
'.$langs->trans('AmountHT').''.price($object->total_ht).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->trans('AmountVAT').''.price($object->total_tva).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc).''.$langs->trans('Currency'.$conf->currency).'
'; - - print ''; - if ($action != 'classify') - { - print ''; - } - print '
'; - print $langs->trans('Project'); - print 'id.'">'; - print img_edit($langs->trans('SetProject'),1); - print '
'; - - print '
'; - if ($action == 'classify') - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,'projectid'); - } - else - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,'none'); - } - print '
'; - - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - print '
'; - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { - $colwidth=20; - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - - /* - * Lines - */ - print '
'; - print ''; - $var=1; - $num=count($object->lines); - for ($i = 0; $i < $num; $i++) - { - if ($i == 0) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - - // Show product and description - $type=(! empty($object->lines[$i]->product_type)?$object->lines[$i]->product_type:(! empty($object->lines[$i]->fk_product_type)?$object->lines[$i]->fk_product_type:0)); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - $date_start=''; - $date_end=''; - if (! empty($object->lines[$i]->date_start)) - { - $date_start=$object->lines[$i]->date_start; - $type=1; - } - if (! empty($object->lines[$i]->date_end)) - { - $date_end=$object->lines[$i]->date_end; - $type=1; - } - - $var=!$var; - - // Edit line - if ($object->statut == 0 && $action == 'edit_line' && $_GET['etat'] == '0' && $_GET['lineid'] == $object->lines[$i]->rowid) - { - print 'lines[$i]->rowid.'" method="post">'; - print ''; - print ''; - print ''; - - // Show product and description - print ''; - - // VAT - print ''; - - // Unit price - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - print ''; - } - else // Affichage simple de la ligne - { - print ''; - - // Show product and description - print ''; - - // VAT - print ''; - - // Unit price - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - } - - } - - /* - * Form to add new line - */ - - if ($object->statut == 0 && $action != 'edit_line') - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Add free products/services form - print ''; - print ''; - print ''; - print ''; - - $var=true; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Ajout de produits/services predefinis - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - $var=! $var; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } - - print '
'.$langs->trans('Label').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('TotalHTShort').''.$langs->trans('TotalTTCShort').'  
'; - if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $object->lines[$i]->fk_product) - { - print ''; - $product_static=new ProductFournisseur($db); - $product_static->fetch($object->lines[$i]->fk_product); - $text=$product_static->getNomUrl(1); - $text.= ' - '.$product_static->libelle; - print $text; - print '
'; - } - else - { - $forceall=1; // For suppliers, we always show all types - print $form->select_type_of_lines($object->lines[$i]->product_type,'type',1); - if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) - || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '
'; - } - - if (is_object($hookmanager)) - { - $parameters=array('fk_parent_line'=>$line->fk_parent_line, 'line'=>$object->lines[$i],'var'=>$var,'num'=>$num,'i'=>$i); - $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action); - } - - // Description - Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('desc',$object->lines[$i]->description,'',128,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); - $doleditor->Create(); - print '
'; - print $form->load_tva('tauxtva',$object->lines[$i]->tva_tx,$societe,$mysoc); - print '%  '; - print '
'; - if ($object->lines[$i]->fk_product) - { - print ''; // ancre pour retourner sur la ligne - - $product_static=new ProductFournisseur($db); - $product_static->fetch($object->lines[$i]->fk_product); - $text=$product_static->getNomUrl(1); - $text.= ' - '.$product_static->libelle; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($object->lines[$i]->description)); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($date_start,$date_end); - - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) print ($object->lines[$i]->description && $object->lines[$i]->description!=$product_static->libelle)?'
'.dol_htmlentitiesbr($object->lines[$i]->description):''; - } - - // Description - Editor wysiwyg - if (! $object->lines[$i]->fk_product) - { - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.nl2br($object->lines[$i]->description); - - // Show range - print_date_range($date_start,$date_end); - } - print '
'.vatrate($object->lines[$i]->tva_tx).'%'.price($object->lines[$i]->pu_ht,'MU').''.($object->lines[$i]->pu_ttc?price($object->lines[$i]->pu_ttc,'MU'):' ').''.$object->lines[$i]->qty.''.(($object->lines[$i]->remise_percent > 0)?$object->lines[$i]->remise_percent.'%':'').''.price($object->lines[$i]->total_ht).''.price($object->lines[$i]->total_ttc).''; - if ($object->statut == 0) print 'lines[$i]->rowid.'">'.img_edit().''; - else print ' '; - print ''; - if ($object->statut == 0) print 'lines[$i]->rowid.'">'.img_delete().''; - else print ' '; - print '
'; - print ''; // ancre - print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').'     
'; - - $forceall=1; // For suppliers, we always show all types - print $form->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1,0,$forceall); - if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) - || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '
'; - - if (is_object($hookmanager)) - { - $parameters=array(); - $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); - } - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('dp_desc',GETPOST("dp_desc"),'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); - $doleditor->Create(); - - print '
'; - print $form->load_tva('tauxtva',(GETPOST('tauxtva')?GETPOST('tauxtva'):-1),$societe,$mysoc); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '%  
'; - print $langs->trans("AddNewLine").' - '; - if (! empty($conf->service->enabled)) - { - print $langs->trans('RecordedProductsAndServices'); - } - else - { - print $langs->trans('RecordedProducts'); - } - print ''.$langs->trans('Qty').'   
'; - - $ajaxoptions=array( - 'update' => array('pqty' => 'qty', 'p_remise_percent' => 'discount'), - 'disabled' => 'addPredefinedProductButton', - 'error' => $langs->trans("NoPriceDefinedForThisSupplier") - ); - $form->select_produits_fournisseurs($object->socid, '', 'idprodfournprice', '', '', $ajaxoptions); - - if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) print '
'; - - if (is_object($hookmanager)) - { - $parameters=array('htmlname'=>'idprodfournprice'); - $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action); - } - - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor = new DolEditor('np_desc', GETPOST('np_desc'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, $nbrows, 70); - $doleditor->Create(); - - print '
%  
'; - - print ''; - - if ($action != 'presend') - { - - /* - * Boutons actions - */ - - print '
'; - - // Reopen a standard paid invoice - if (($object->type == 0 || $object->type == 1) && ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely) - { - if (! $facidnext && $object->close_code != 'replaced') // Not replaced by another invoice - { - print ''.$langs->trans('ReOpen').''; - } - else - { - print ''.$langs->trans('ReOpen').''; - } - } - - // Send by mail - if (($object->statut == 1 || $object->statut == 2)) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send) - { - print ''.$langs->trans('SendByMail').''; - } - else print ''.$langs->trans('SendByMail').''; - } - - - //Make payments - if ($action != 'edit' && $object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) - { - print ''.$langs->trans('DoPayment').''; - } - - //Classify paid - if ($action != 'edit' && $object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) - { - print ''.$langs->trans('ClassifyPaid').''; - - //print ''.$langs->trans('ClassifyPaid').''; - } - - //Validate - if ($action != 'edit' && $object->statut == 0) - { - if (count($object->lines)) - { - if ($user->rights->fournisseur->facture->valider) - { - print ''.$langs->trans('Validate').''; - } - else - { - print ''.$langs->trans('Validate').''; - } - } - } - - //Clone - if ($action != 'edit' && $user->rights->fournisseur->facture->creer) - { - print 'socid.'">'.$langs->trans('ToClone').''; - } - - //Delete - if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer) - { - print ''.$langs->trans('Delete').''; - } - print '
'; - - if ($action != 'edit') - { - print '
'; - print ''; // ancre - - /* - * Documents generes - */ - - $ref=dol_sanitizeFileName($object->ref); - $subdir = get_exdir($object->id,2).$ref; - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref; - $urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id; - $genallowed=$user->rights->fournisseur->facture->creer; - $delallowed=$user->rights->fournisseur->facture->supprimer; - $modelpdf=(! empty($object->modelpdf)?$object->modelpdf:''); - - print '
'; - print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,0,0,'','','',$societe->default_lang); - $somethingshown=$formfile->numoffiles; - - /* - * Linked object block - */ - $somethingshown=$object->showLinkedObjectBlock(); - - print '
'; - print '
'; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'invoice_supplier',$socid); - - print '
'; - } - } - /* - * Show mail form - */ - if ($action == 'presend') - { - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref); - $file=$fileparams['fullname']; - - // Build document if it not exists - if (! $file || ! is_readable($file)) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $result=supplier_invoice_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref); - $file=$fileparams['fullname']; - } - - print '
'; - print_titre($langs->trans('SendBillByMail')); - - // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - $formmail->withfrom=1; - $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$soc->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtocccsocid=0; - $formmail->withtopic=$langs->trans('SendBillRef','__FACREF__'); - $formmail->withfile=2; - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__FACREF__']=$object->ref; - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__PERSONALIZED__']=''; - // Tableau des parametres complementaires - $formmail->param['action']='send'; - $formmail->param['models']='invoice_supplier_send'; - $formmail->param['facid']=$object->id; - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - // Init list of files - if (GETPOST("mode")=='init') - { - $formmail->clear_attached_files(); - $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); - } - - // Show form - $formmail->show_form(); - - print '
'; - } - } -} - - -// End of page -llxFooter(); -$db->close(); -?> \ No newline at end of file + $result=$object->update($user); + if ($result < 0) dol_print_error($db,$object->error); +} +elseif ($action == 'setnote_public' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} +elseif ($action == 'setnote' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +// Delete payment +elseif ($action == 'deletepaiement') +{ + $object->fetch($id); + if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) + { + $paiementfourn = new PaiementFourn($db); + $paiementfourn->fetch(GETPOST('paiement_id')); + $result=$paiementfourn->delete(); + if ($result < 0) $mesg='
'.$paiementfourn->error.'
'; + } +} + +// Create +elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) +{ + $error=0; + + $datefacture=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); + $datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); + + if ($datefacture == '') + { + $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')).'
'; + $action='create'; + $_GET['socid']=$_POST['socid']; + $error++; + } + if (! GETPOST('facnumber')) + { + $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')).'
'; + $action='create'; + $_GET['socid']=$_POST['socid']; + $error++; + } + + if (! $error) + { + $db->begin(); + + // Creation facture + $object->ref = $_POST['facnumber']; + $object->socid = $_POST['socid']; + $object->libelle = $_POST['libelle']; + $object->date = $datefacture; + $object->date_echeance = $datedue; + $object->note_public = $_POST['note']; + + // If creation from another object of another module + if ($_POST['origin'] && $_POST['originid']) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $_POST['origin']; + /*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + }*/ + + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } + if ($element == 'order_supplier') { + $element = 'fourn'; $subelement = 'fournisseur.commande'; + } + + $object->origin = $_POST['origin']; + $object->origin_id = $_POST['originid']; + + $id = $object->create($user); + + // Add lines + if ($id > 0) + { + require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + $classname = ucfirst($subelement); + if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + $srcobject = new $classname($db); + + $result=$srcobject->fetch($_POST['originid']); + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); + + $num=count($lines); + for ($i = 0; $i < $num; $i++) + { + $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + + // Dates + // TODO mutualiser + $date_start=$lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_end=$lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->qty, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + 'HT', + $product_type + ); + + if ($result < 0) + { + $error++; + break; + } + } + } + else + { + $error++; + } + } + else + { + $error++; + } + } + // If some invoice's lines already known + else + { + $id = $object->create($user); + if ($id < 0) + { + $error++; + } + + if (! $error) + { + for ($i = 1 ; $i < 9 ; $i++) + { + $label = $_POST['label'.$i]; + $amountht = price2num($_POST['amount'.$i]); + $amountttc = price2num($_POST['amountttc'.$i]); + $tauxtva = price2num($_POST['tauxtva'.$i]); + $qty = $_POST['qty'.$i]; + $fk_product = $_POST['fk_product'.$i]; + if ($label) + { + if ($amountht) + { + $price_base='HT'; $amount=$amountht; + } + else + { + $price_base='TTC'; $amount=$amountttc; + } + $atleastoneline=1; + + $product=new Product($db); + $product->fetch($_POST['idprod'.$i]); + + $ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base); + if ($ret < 0) $error++; + } + } + } + } + + if ($error) + { + $langs->load("errors"); + $db->rollback(); + $mesg='
'.$langs->trans($object->error).'
'; + $action='create'; + $_GET['socid']=$_POST['socid']; + } + else + { + $db->commit(); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } + } +} + +// Modification d'une ligne +elseif ($action == 'update_line') +{ + if (GETPOST('etat') == '1' && ! GETPOST('cancel')) // si on valide la modification + { + $object->fetch($id); + $object->fetch_thirdparty(); + + if ($_POST['puht']) + { + $pu=$_POST['puht']; + $price_base_type='HT'; + } + if ($_POST['puttc']) + { + $pu=$_POST['puttc']; + $price_base_type='TTC'; + } + + if (GETPOST('idprod')) + { + $prod = new Product($db); + $prod->fetch($_POST['idprod']); + $label = $prod->description; + if (trim($_POST['desc']) != trim($label)) $label=$_POST['desc']; + + $type = $prod->type; + } + else + { + + $label = $_POST['desc']; + $type = $_POST["type"]?$_POST["type"]:0; + + } + + $localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty); + $localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty); + $remise_percent=GETPOST('remise_percent'); + + $result=$object->updateline(GETPOST('lineid'), $label, $pu, GETPOST('tauxtva'), $localtax1tx, $localtax2tx, GETPOST('qty'), GETPOST('idprod'), $price_base_type, 0, $type, $remise_percent); + if ($result >= 0) + { + unset($_POST['label']); + } + } +} + +elseif ($action == 'addline') +{ + $ret=$object->fetch($id); + if ($ret < 0) + { + dol_print_error($db,$object->error); + exit; + } + $ret=$object->fetch_thirdparty(); + + if ($_POST['idprodfournprice']) // > 0 or -1 + { + $product=new Product($db); + $idprod=$product->get_buyprice($_POST['idprodfournprice'], $_POST['qty']); // Just to see if a price exists for the quantity. Not used to found vat + + if ($idprod > 0) + { + $result=$product->fetch($idprod); + + // cas special pour lequel on a les meme reference que le fournisseur + // $label = '['.$product->ref.'] - '. $product->libelle; + $label = $product->description; + $label.= $product->description && $_POST['np_desc'] ? "\n" : ""; + $label.= $_POST['np_desc']; + + $tvatx=get_default_tva($object->thirdparty, $mysoc, $product->id, $_POST['idprodfournprice']); + + $localtax1tx= get_localtax($tvatx, 1, $object->thirdparty); + $localtax2tx= get_localtax($tvatx, 2, $object->thirdparty); + $remise_percent=GETPOST('remise_percent'); + $type = $product->type; + + $result=$object->addline($label, $product->fourn_pu, $tvatx, $localtax1tx, $localtax2tx, $_POST['qty'], $idprod, $remise_percent); + + } + if ($idprod == -1) + { + // Quantity too low + $langs->load("errors"); + $mesg='
'.$langs->trans("ErrorQtyTooLowForThisSupplier").'
'; + } + } + else + { + $tauxtva = price2num($_POST['tauxtva']); + $localtax1tx= get_localtax($tauxtva, 1, $object->thirdparty); + $localtax2tx= get_localtax($tauxtva, 2, $object->thirdparty); + $remise_percent=GETPOST('remise_percent'); + + if (! $_POST['dp_desc']) + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Description")).'
'; + } + else + { + $type = $_POST["type"]; + if (! empty($_POST['amount'])) + { + $ht = price2num($_POST['amount']); + $price_base_type = 'HT'; + + //$desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0) + $result=$object->addline($_POST['dp_desc'], $ht, $tauxtva, $localtax1tx, $localtax2tx, $_POST['qty'], 0, $remise_percent, $datestart, $dateend, 0, 0, $price_base_type, $type); + } + else + { + $ttc = price2num($_POST['amountttc']); + $ht = $ttc / (1 + ($tauxtva / 100)); + $price_base_type = 'HT'; + $result=$object->addline($_POST['dp_desc'], $ht, $tauxtva,$localtax1tx, $localtax2tx, $_POST['qty'], 0, $remise_percent, $datestart, $dateend, 0, 0, $price_base_type, $type); + } + } + } + + //print "xx".$tva_tx; exit; + if ($result > 0) + { + // Define output language + $outputlangs = $langs; + $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprodfournprice']); + unset($_POST['remise_percent']); + unset($_POST['dp_desc']); + unset($_POST['np_desc']); + unset($_POST['pu']); + unset($_POST['tva_tx']); + unset($_POST['label']); + unset($localtax1_tx); + unset($localtax2_tx); + } + else if (empty($mesg)) + { + $mesg='
'.$object->error.'
'; + } + + $action = ''; +} + +elseif ($action == 'classin') +{ + $object->fetch($id); + $result=$object->setProject($_POST['projectid']); +} + + +// Set invoice to draft status +elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($id); + + $totalpaye = $object->getSommePaiement(); + $resteapayer = $object->total_ttc - $totalpaye; + + // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees + //$ventilExportCompta = $object->getVentilExportCompta(); + + // On verifie si aucun paiement n'a ete effectue + if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) + { + $object->set_draft($user); + + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + } +} + +// Set invoice to validated/unpaid status +elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer) +{ + $result = $object->fetch($id); + if ($object->statut == 2 + || ($object->statut == 3 && $object->close_code != 'replaced')) + { + $result = $object->set_unpaid($user); + if ($result > 0) + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; + } + else + { + $mesg='
'.$object->error.'
'; + } + } +} + +// Add file in email form +if (GETPOST('addfile')) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + dol_add_file_process($upload_dir_tmp,0,0); + $action='presend'; +} + +// Remove file in email form +if (! empty($_POST['removedfile'])) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + // TODO Delete only files that was uploaded from email form + dol_remove_file_process($_POST['removedfile'],0); + $action='presend'; +} + +// Send mail +if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) +{ + $langs->load('mails'); + + $object->fetch($id); + $result=$object->fetch_thirdparty(); + if ($result > 0) + { +// $ref = dol_sanitizeFileName($object->ref); +// $file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref.'/'.$ref.'.pdf'; + +// if (is_readable($file)) +// { + if ($_POST['sendto']) + { + // Le destinataire a ete fourni via le champ libre + $sendto = $_POST['sendto']; + $sendtoid = 0; + } + elseif ($_POST['receiver'] != '-1') + { + // Recipient was provided from combo list + if ($_POST['receiver'] == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } + else // Id du contact + { + $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); + $sendtoid = $_POST['receiver']; + } + } + + if (dol_strlen($sendto)) + { + $langs->load("commercial"); + + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; + $message = $_POST['message']; + $sendtocc = $_POST['sendtocc']; + $deliveryreceipt = $_POST['deliveryreceipt']; + + if ($action == 'send') + { + if (dol_strlen($_POST['subject'])) $subject=$_POST['subject']; + else $subject = $langs->transnoentities('CustomerOrder').' '.$object->ref; + $actiontypecode='AC_SUP_ORD'; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + if ($message) + { + $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; + $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; + $actionmsg.=$message; + } + $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } + + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + + // Send mail + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); + if ($mailfile->error) + { + $mesg='
'.$mailfile->error.'
'; + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " + + $error=0; + + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('BILL_SUPPLIER_SENTBYMAIL',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + + if ($error) + { + dol_print_error($db); + } + else + { + // Redirect here + // This avoid sending mail twice if going out and then back to page + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mesg='.urlencode($mesg)); + exit; + } + } + else + { + $langs->load("other"); + $mesg='
'; + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='
'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg.='
'; + } + } + } + + else + { + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; + dol_syslog('Recipient email is empty'); + } +/* } + else + { + $langs->load("errors"); + $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; + dol_syslog('Failed to read file: '.$file); + }*/ + } + else + { + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'
'; + dol_syslog('Unable to read data from the invoice. The invoice file has perhaps not been generated.'); + } + + //$action = 'presend'; +} + +// Build document +elseif ($action == 'builddoc') +{ + // Save modele used + $object->fetch($id); + $object->fetch_thirdparty(); + if ($_REQUEST['model']) + { + $object->setDocModel($user, $_REQUEST['model']); + } + + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + $result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + exit; + } +} + +// Delete file in doc form +elseif ($action == 'remove_file') +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + if ($object->fetch($id)) + { + $object->fetch_thirdparty(); + $upload_dir = $conf->fournisseur->facture->dir_output . "/"; + $file = $upload_dir . '/' . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + } +} + +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer) +{ + if ($action == 'addcontact') + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut') + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact') + { + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } + } +} + + +/* + * View + */ + +$form = new Form($db); +$formfile = new FormFile($db); +$bankaccountstatic=new Account($db); + +llxHeader('','',''); + +// Mode creation +if ($action == 'create') +{ + print_fiche_titre($langs->trans('NewBill')); + + dol_htmloutput_mesg($mesg); + + $societe=''; + if ($_GET['socid']) + { + $societe=new Societe($db); + $societe->fetch($_GET['socid']); + } + + if (GETPOST('origin') && GETPOST('originid')) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = GETPOST('origin'); + + if ($element == 'project') + { + $projectid=GETPOST('originid'); + } + else if (in_array($element,array('order_supplier'))) + { + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + dol_htmloutput_errors('',$errors); + $element = 'comm/propal'; $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } + if ($element == 'order_supplier') { + $element = 'fourn'; $subelement = 'fournisseur.commande'; + } + + require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + $classname = ucfirst($subelement); + if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + $objectsrc = new $classname($db); + $objectsrc->fetch(GETPOST('originid')); + $objectsrc->fetch_thirdparty(); + + $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + //$ref_client = (!empty($objectsrc->ref_client)?$object->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)); + $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; + + $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); + $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); + $datedue=($datetmp==''?-1:$datetmp); + } + } + else + { + $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); + $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); + $datedue=($datetmp==''?-1:$datetmp); + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Ref + print ''; + + // Third party + print ''; + print ''; + + // Ref supplier + print ''; + print ''; + + print ''; + + // Label + print ''; + + // Date invoice + print ''; + + // Due date + print ''; + + print ''; + print ''; + print ''; + + if (is_object($objectsrc)) + { + print "\n"; + print "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + + $txt=$langs->trans($classname); + if ($classname=='CommandeFournisseur') $txt=$langs->trans("SupplierOrder"); + print ''; + print ''; + print '"; + if ($mysoc->country_code=='ES') + { + if ($mysoc->localtax1_assuj=="1") //Localtax1 RE + { + print '"; + } + + if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF + { + print '"; + } + } + print '"; + } + else + { + // TODO more bugs + if (1==2 && ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + for ($i = 1 ; $i < 9 ; $i++) + { + $value_qty = '1'; + $value_tauxtva = ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + } + } + + // Other options + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + + // Bouton "Create Draft" + print "
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Supplier').''; + + if ($_REQUEST['socid'] > 0) + { + print $societe->getNomUrl(1); + print ''; + } + else + { + print $form->select_company((empty($_GET['socid'])?'':$_GET['socid']),'socid','s.fournisseur = 1',1); + } + print '
'.$langs->trans('RefSupplier').'
'.$langs->trans('Type').''; + print ''."\n"; + + // Standard invoice + print ''."\n"; + + /* + // Deposit + print ''."\n"; + + // Proforma + if (! empty($conf->global->FACTURE_USE_PROFORMAT)) + { + print ''."\n"; + } + + // Replacement + print ''; + + // Credit note + print ''."\n"; + */ + print '
'; + print ''; + print ''; + $desc=$form->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); + print $desc; + print '
'; + print ''; + print ''; + $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); + print $desc; + print '
'; + print ''; + print ''; + $desc=$form->textwithpicto($langs->trans("InvoiceProForma"),$langs->transnoentities("InvoiceProFormaDesc"),1); + print $desc; + print '
'; + print ''; + print ''; + $text=$langs->trans("InvoiceReplacementAsk").' '; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + print $desc; + print '
'; + print ''; + print ''; + $text=$langs->transnoentities("InvoiceAvoirAsk").' '; + // $text.=''; + $text.=''; + $desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); + print $desc; + print '
'; + print '
'.$langs->trans('Label').'
'.$langs->trans('DateInvoice').''; + $form->select_date($dateinvoice,'','','','',"add",1,1); + print '
'.$langs->trans('DateMaxPayment').''; + $form->select_date($datedue,'ech','','','',"add",1,1); + print '
'.$langs->trans('NotePublic').'
'.$txt.''.$objectsrc->getNomUrl(1).'
'.$langs->trans('TotalHT').''.price($objectsrc->total_ht).'
'.$langs->trans('TotalVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('TotalTTC').''.price($objectsrc->total_ttc)."
 '.$langs->trans('Label').''.$langs->trans('PriceUHT').''.$langs->trans('VAT').''.$langs->trans('Qty').''.$langs->trans('PriceUTTC').'
'.$i.''; + print $form->load_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc); + print '
\n"; + + print '
'; + + print "
\n"; + + + // Show origin lines + if (is_object($objectsrc)) + { + print '
'; + + $title=$langs->trans('ProductsAndServices'); + print_titre($title); + + print ''; + + $objectsrc->printOriginLinesList($hookmanager); + + print '
'; + } +} +else +{ + if ($id > 0) + { + /* *************************************************************************** */ + /* */ + /* Fiche en mode visu ou edition */ + /* */ + /* *************************************************************************** */ + + $now=dol_now(); + + $productstatic = new Product($db); + + $object->fetch($id); + + $societe = new Fournisseur($db); + $societe->fetch($object->socid); + + /* + * View card + */ + $head = facturefourn_prepare_head($object); + $titre=$langs->trans('SupplierInvoice'); + dol_fiche_head($head, 'card', $titre, 0, 'bill'); + + dol_htmloutput_mesg($mesg); + dol_htmloutput_errors('',$errors); + + // Confirmation de la suppression d'une ligne produit + if ($action == 'confirm_delete_line') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 1, 1); + if ($ret == 'html') print '
'; + } + + // Clone confirmation + if ($action == 'clone') + { + // Create an array for form + $formquestion=array( + //'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) + ); + // Paiement incomplet. On demande si motif = escompte ou autre + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$object->ref),'confirm_clone',$formquestion,'yes', 1); + if ($ret == 'html') print '
'; + } + + // Confirmation de la validation + if ($action == 'valid') + { + $formquestion=array(); + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $object->hasProductsOrServices(1)) + { + $langs->load("stocks"); + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct=new FormProduct($db); + $formquestion=array( + //'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); + } + + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $object->ref), 'confirm_valid', $formquestion, 1, 1, 240); + if ($ret == 'html') print '
'; + } + + // Confirmation set paid + if ($action == 'paid') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', 0, 1); + if ($ret == 'html') print '
'; + } + + // Confirmation de la suppression de la facture fournisseur + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1); + if ($ret == 'html') print '
'; + } + + + /** + * Invoice + */ + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + print "\n"; + + // Ref supplier + print ''; + + // Third party + print ''; + print ''; + + // Type + print ''; + + // Label + print ''; + print ''; + + /* + * List of payments + */ + $nbrows=7; $nbcols=2; + if (! empty($conf->projet->enabled)) $nbrows++; + if (! empty($conf->banque->enabled)) $nbcols++; + + // Local taxes + if ($mysoc->country_code=='ES') + { + if($mysoc->localtax1_assuj=="1") $nbrow++; + if($mysoc->localtax2_assuj=="1") $nbrow++; + } + + print ''; + + print ''; + + // Date + print ''; + + // Due date + print ''; + + // Status + $alreadypaid=$object->getSommePaiement(); + print ''; + + print ''; + print ''; + + // Amount Local Taxes + if ($mysoc->country_code=='ES') + { + if ($mysoc->localtax1_assuj=="1") //Localtax1 RE + { + print ''; + print ''; + print ''; + } + if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF + { + print ''; + print ''; + print ''; + } + } + print ''; + + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load('projects'); + print ''; + print ''; + print ''; + } + + // Other options + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref'); + print '
'.$form->editfieldkey("RefSupplier",'facnumber',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).''; + print $form->editfieldval("RefSupplier",'facnumber',$object->ref_supplier,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)); + print '
'.$langs->trans('Supplier').''.$societe->getNomUrl(1); + print '   ('.$langs->trans('OtherBills').')
'.$langs->trans('Type').''; + print $object->getLibType(); + if ($object->type == 1) + { + $facreplaced=new FactureFournisseur($db); + $facreplaced->fetch($object->fk_facture_source); + print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; + } + if ($object->type == 2) + { + $facusing=new FactureFournisseur($db); + $facusing->fetch($object->fk_facture_source); + print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')'; + } + + $facidavoir=$object->getListIdAvoirFromInvoice(); + if (count($facidavoir) > 0) + { + print ' ('.$langs->transnoentities("InvoiceHasAvoir"); + $i=0; + foreach($facidavoir as $id) + { + if ($i==0) print ' '; + else print ','; + $facavoir=new FactureFournisseur($db); + $facavoir->fetch($id); + print $facavoir->getNomUrl(1); + } + print ')'; + } + if (isset($facidnext) && $facidnext > 0) + { + $facthatreplace=new FactureFournisseur($db); + $facthatreplace->fetch($facidnext); + print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; + } + print '
'.$form->editfieldkey("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).''.$form->editfieldval("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).''; + + $sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,'; + $sql.= ' c.libelle as paiement_type,'; + $sql.= ' pf.amount,'; + $sql.= ' ba.rowid as baid, ba.ref, ba.label'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; + $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; + $sql.= ' ORDER BY p.datep, p.tms'; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; $totalpaye = 0; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print ''; + print ''; + print ''; + + $var=true; + if ($num > 0) + { + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print '\n"; + print ''; + if (! empty($conf->banque->enabled)) + { + $bankaccountstatic->id=$objp->baid; + $bankaccountstatic->ref=$objp->ref; + $bankaccountstatic->label=$objp->ref; + print ''; + } + print ''; + print ''; + print ''; + $totalpaye += $objp->amount; + $i++; + } + } + else + { + print ''; + } + + if ($object->paye == 0) + { + print ''; + print ''; + + $resteapayer = $object->total_ttc - $totalpaye; + + print ''; + print ''; + } + print '
'.$langs->trans('Payments').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
'.img_object($langs->trans('ShowPayment'),'payment').' '.dol_print_date($db->jdate($objp->dp),'day')."'.$objp->paiement_type.' '.$objp->num_paiement.''; + print $bankaccountstatic->getNomUrl(1,'transactions'); + print ''.price($objp->amount).''; + if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) + { + print 'rowid.'">'; + print img_delete(); + print ''; + } + print '
'.$langs->trans("None").'
'.$langs->trans('AlreadyPaid').' :'.price($totalpaye).'
'.$langs->trans("Billed").' :'.price($object->total_ttc).'
'.$langs->trans('RemainderToPay').' :'.price($resteapayer).'
'; + $db->free($result); + } + else + { + dol_print_error($db); + } + print '
'.$form->editfieldkey("Date",'datef',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').''; + print $form->editfieldval("Date",'datef',$object->datep,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker'); + print '
'.$form->editfieldkey("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').''; + print $form->editfieldval("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker'); + if ($action != 'editdate_lim_reglement' && $object->statut < 2 && $object->date_echeance && $object->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_warning($langs->trans('Late')); + print '
'.$langs->trans('Status').''.$object->getLibStatut(4,$alreadypaid).'
'.$langs->trans('AmountHT').''.price($object->total_ht).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->trans('AmountVAT').''.price($object->total_tva).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc).''.$langs->trans('Currency'.$conf->currency).'
'; + + print ''; + if ($action != 'classify') + { + print ''; + } + print '
'; + print $langs->trans('Project'); + print 'id.'">'; + print img_edit($langs->trans('SetProject'),1); + print '
'; + + print '
'; + if ($action == 'classify') + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,'projectid'); + } + else + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id,$object->socid,$object->fk_project,'none'); + } + print '
'; + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + print '
'; + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $colwidth=20; + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + + /* + * Lines + */ + print '
'; + print ''; + $var=1; + $num=count($object->lines); + for ($i = 0; $i < $num; $i++) + { + if ($i == 0) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + // Show product and description + $type=(! empty($object->lines[$i]->product_type)?$object->lines[$i]->product_type:(! empty($object->lines[$i]->fk_product_type)?$object->lines[$i]->fk_product_type:0)); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + $date_start=''; + $date_end=''; + if (! empty($object->lines[$i]->date_start)) + { + $date_start=$object->lines[$i]->date_start; + $type=1; + } + if (! empty($object->lines[$i]->date_end)) + { + $date_end=$object->lines[$i]->date_end; + $type=1; + } + + $var=!$var; + + // Edit line + if ($object->statut == 0 && $action == 'edit_line' && $_GET['etat'] == '0' && $_GET['lineid'] == $object->lines[$i]->rowid) + { + print 'lines[$i]->rowid.'" method="post">'; + print ''; + print ''; + print ''; + + // Show product and description + print ''; + + // VAT + print ''; + + // Unit price + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + print ''; + } + else // Affichage simple de la ligne + { + print ''; + + // Show product and description + print ''; + + // VAT + print ''; + + // Unit price + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + } + + } + + /* + * Form to add new line + */ + + if ($object->statut == 0 && $action != 'edit_line') + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Add free products/services form + print ''; + print ''; + print ''; + print ''; + + $var=true; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Ajout de produits/services predefinis + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + $var=! $var; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + } + + print '
'.$langs->trans('Label').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('TotalHTShort').''.$langs->trans('TotalTTCShort').'  
'; + if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $object->lines[$i]->fk_product) + { + print ''; + $product_static=new ProductFournisseur($db); + $product_static->fetch($object->lines[$i]->fk_product); + $text=$product_static->getNomUrl(1); + $text.= ' - '.$product_static->libelle; + print $text; + print '
'; + } + else + { + $forceall=1; // For suppliers, we always show all types + print $form->select_type_of_lines($object->lines[$i]->product_type,'type',1); + if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) + || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '
'; + } + + if (is_object($hookmanager)) + { + $parameters=array('fk_parent_line'=>$line->fk_parent_line, 'line'=>$object->lines[$i],'var'=>$var,'num'=>$num,'i'=>$i); + $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action); + } + + // Description - Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $doleditor=new DolEditor('desc',$object->lines[$i]->description,'',128,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor->Create(); + print '
'; + print $form->load_tva('tauxtva',$object->lines[$i]->tva_tx,$societe,$mysoc); + print '%  '; + print '
'; + if ($object->lines[$i]->fk_product) + { + print ''; // ancre pour retourner sur la ligne + + $product_static=new ProductFournisseur($db); + $product_static->fetch($object->lines[$i]->fk_product); + $text=$product_static->getNomUrl(1); + $text.= ' - '.$product_static->libelle; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($object->lines[$i]->description)); + print $form->textwithtooltip($text,$description,3,'','',$i); + + // Show range + print_date_range($date_start,$date_end); + + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) print ($object->lines[$i]->description && $object->lines[$i]->description!=$product_static->libelle)?'
'.dol_htmlentitiesbr($object->lines[$i]->description):''; + } + + // Description - Editor wysiwyg + if (! $object->lines[$i]->fk_product) + { + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + print $text.' '.nl2br($object->lines[$i]->description); + + // Show range + print_date_range($date_start,$date_end); + } + print '
'.vatrate($object->lines[$i]->tva_tx).'%'.price($object->lines[$i]->pu_ht,'MU').''.($object->lines[$i]->pu_ttc?price($object->lines[$i]->pu_ttc,'MU'):' ').''.$object->lines[$i]->qty.''.(($object->lines[$i]->remise_percent > 0)?$object->lines[$i]->remise_percent.'%':'').''.price($object->lines[$i]->total_ht).''.price($object->lines[$i]->total_ttc).''; + if ($object->statut == 0) print 'lines[$i]->rowid.'">'.img_edit().''; + else print ' '; + print ''; + if ($object->statut == 0) print 'lines[$i]->rowid.'">'.img_delete().''; + else print ' '; + print '
'; + print ''; // ancre + print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').'     
'; + + $forceall=1; // For suppliers, we always show all types + print $form->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1,0,$forceall); + if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) + || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '
'; + + if (is_object($hookmanager)) + { + $parameters=array(); + $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + } + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $doleditor=new DolEditor('dp_desc',GETPOST("dp_desc"),'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor->Create(); + + print '
'; + print $form->load_tva('tauxtva',(GETPOST('tauxtva')?GETPOST('tauxtva'):-1),$societe,$mysoc); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '%  
'; + print $langs->trans("AddNewLine").' - '; + if (! empty($conf->service->enabled)) + { + print $langs->trans('RecordedProductsAndServices'); + } + else + { + print $langs->trans('RecordedProducts'); + } + print ''.$langs->trans('Qty').'   
'; + + $ajaxoptions=array( + 'update' => array('pqty' => 'qty', 'p_remise_percent' => 'discount'), + 'disabled' => 'addPredefinedProductButton', + 'error' => $langs->trans("NoPriceDefinedForThisSupplier") + ); + $form->select_produits_fournisseurs($object->socid, '', 'idprodfournprice', '', '', $ajaxoptions); + + if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) print '
'; + + if (is_object($hookmanager)) + { + $parameters=array('htmlname'=>'idprodfournprice'); + $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action); + } + + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $doleditor = new DolEditor('np_desc', GETPOST('np_desc'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, $nbrows, 70); + $doleditor->Create(); + + print '
%  
'; + + print ''; + + if ($action != 'presend') + { + + /* + * Boutons actions + */ + + print '
'; + + // Reopen a standard paid invoice + if (($object->type == 0 || $object->type == 1) && ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely) + { + if (! $facidnext && $object->close_code != 'replaced') // Not replaced by another invoice + { + print ''.$langs->trans('ReOpen').''; + } + else + { + print ''.$langs->trans('ReOpen').''; + } + } + + // Send by mail + if (($object->statut == 1 || $object->statut == 2)) + { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send) + { + print ''.$langs->trans('SendByMail').''; + } + else print ''.$langs->trans('SendByMail').''; + } + + + //Make payments + if ($action != 'edit' && $object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) + { + print ''.$langs->trans('DoPayment').''; + } + + //Classify paid + if ($action != 'edit' && $object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) + { + print ''.$langs->trans('ClassifyPaid').''; + + //print ''.$langs->trans('ClassifyPaid').''; + } + + //Validate + if ($action != 'edit' && $object->statut == 0) + { + if (count($object->lines)) + { + if ($user->rights->fournisseur->facture->valider) + { + print ''.$langs->trans('Validate').''; + } + else + { + print ''.$langs->trans('Validate').''; + } + } + } + + //Clone + if ($action != 'edit' && $user->rights->fournisseur->facture->creer) + { + print 'socid.'">'.$langs->trans('ToClone').''; + } + + //Delete + if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer) + { + print ''.$langs->trans('Delete').''; + } + print '
'; + + if ($action != 'edit') + { + print '
'; + print ''; // ancre + + /* + * Documents generes + */ + + $ref=dol_sanitizeFileName($object->ref); + $subdir = get_exdir($object->id,2).$ref; + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref; + $urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id; + $genallowed=$user->rights->fournisseur->facture->creer; + $delallowed=$user->rights->fournisseur->facture->supprimer; + $modelpdf=(! empty($object->modelpdf)?$object->modelpdf:''); + + print '
'; + print $formfile->showdocuments('facture_fournisseur',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,0,0,'','','',$societe->default_lang); + $somethingshown=$formfile->numoffiles; + + /* + * Linked object block + */ + $somethingshown=$object->showLinkedObjectBlock(); + + print '
'; + print '
'; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'invoice_supplier',$socid); + + print '
'; + } + } + /* + * Show mail form + */ + if ($action == 'presend') + { + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref); + $file=$fileparams['fullname']; + + // Build document if it not exists + if (! $file || ! is_readable($file)) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $result=supplier_invoice_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref); + $file=$fileparams['fullname']; + } + + print '
'; + print_titre($langs->trans('SendBillByMail')); + + // Cree l'objet formulaire mail + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; + $formmail->withtosocid=$soc->id; + $formmail->withtocc=1; + $formmail->withtoccsocid=0; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtocccsocid=0; + $formmail->withtopic=$langs->trans('SendBillRef','__FACREF__'); + $formmail->withfile=2; + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; + // Tableau des substitutions + $formmail->substit['__FACREF__']=$object->ref; + $formmail->substit['__SIGNATURE__']=$user->signature; + $formmail->substit['__PERSONALIZED__']=''; + // Tableau des parametres complementaires + $formmail->param['action']='send'; + $formmail->param['models']='invoice_supplier_send'; + $formmail->param['facid']=$object->id; + $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + + // Init list of files + if (GETPOST("mode")=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); + } + + // Show form + $formmail->show_form(); + + print '
'; + } + } +} + + +// End of page +llxFooter(); +$db->close(); +?> diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index aea6868f42a..a423fdbb97a 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -235,6 +235,7 @@ ALTER TABLE llx_propaldet MODIFY COLUMN localtax2_type varchar(1); ALTER TABLE llx_menu MODIFY COLUMN enabled varchar(255) NULL DEFAULT '1'; ALTER TABLE llx_extrafields ADD COLUMN fieldunique INTEGER DEFAULT 0; +ALTER TABLE llx_extrafields ADD COLUMN fieldrequired INTEGER DEFAULT 0; create table llx_socpeople_extrafields ( @@ -772,6 +773,9 @@ ALTER TABLE llx_product_fournisseur_price ADD COLUMN import_key varchar(14) AFTE ALTER TABLE llx_product_stock ADD COLUMN import_key varchar(14) AFTER pmp; ALTER TABLE llx_societe_rib ADD COLUMN import_key varchar(14) AFTER adresse_proprio; +-- Export filter +ALTER TABLE llx_export_model ADD COLUMN filter text AFTER field; + -- [ task #146 ] Remove table llx_categorie_association ALTER TABLE llx_categorie_association DROP FOREIGN KEY fk_categorie_asso_fk_categorie_mere; ALTER TABLE llx_categorie_association DROP FOREIGN KEY fk_categorie_asso_fk_categorie_fille; @@ -802,4 +806,4 @@ ALTER TABLE llx_product_price_by_qty ADD INDEX idx_product_price_by_qty_fk_produ ALTER TABLE llx_product_price_by_qty ADD CONSTRAINT fk_product_price_by_qty_fk_product_price FOREIGN KEY (fk_product_price) REFERENCES llx_product_price (rowid); ALTER TABLE `llx_product_price_by_qty` ADD `remise_percent` DOUBLE NOT NULL DEFAULT '0' AFTER `price_ttc` , -ADD `remise` DOUBLE NOT NULL DEFAULT '0' AFTER `remise_percent`; \ No newline at end of file +ADD `remise` DOUBLE NOT NULL DEFAULT '0' AFTER `remise_percent`; diff --git a/htdocs/install/mysql/tables/llx_export_model.sql b/htdocs/install/mysql/tables/llx_export_model.sql index e61224d8964..360b716849e 100644 --- a/htdocs/install/mysql/tables/llx_export_model.sql +++ b/htdocs/install/mysql/tables/llx_export_model.sql @@ -1,7 +1,7 @@ -- =================================================================== --- Copyright (C) 2001-2003 Rodolphe Quiedeville --- Copyright (C) 2007 Regis Houssin --- Copyright (C) 2011 Laurent Destailleur +-- Copyright (C) 2001-2003 Rodolphe Quiedeville +-- Copyright (C) 2007-2012 Regis Houssin +-- Copyright (C) 2011 Laurent Destailleur -- -- 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 @@ -17,14 +17,15 @@ -- along with this program. If not, see . -- -- --- Liste des modeles de document disponibles -- =================================================================== create table llx_export_model ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_user integer DEFAULT 0 NOT NULL, - label varchar(50) NOT NULL, - type varchar(20) NOT NULL, - field text NOT NULL + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_user integer DEFAULT 0 NOT NULL, + label varchar(50) NOT NULL, + type varchar(20) NOT NULL, + field text NOT NULL, + filter text + )ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index 79eaffc8347..15fc9bce007 100755 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -1,8 +1,6 @@ -- =================================================================== --- Copyright (C) 2002-2003 Rodolphe Quiedeville --- Copyright (C) 2002-2003 Jean-Louis Bergamo --- Copyright (C) 2009 Regis Houssin --- Copyright (C) 2011 Laurent Destailleur +-- Copyright (C) 2011-2012 Regis Houssin +-- Copyright (C) 2011-2012 Laurent Destailleur -- -- 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 @@ -30,5 +28,6 @@ create table llx_extrafields type varchar(8), size varchar(8) DEFAULT NULL, fieldunique integer DEFAULT 0, + fieldrequired integer DEFAULT 0, pos integer DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 4665da31baf..8ad807a88de 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -123,4 +123,8 @@ SuppliersProducts=Produits Fournisseurs BankCode=Code banque DeskCode=Code guichet BankAccountNumber=Numéro compte -BankAccountNumberKey=Clé RIB \ No newline at end of file +BankAccountNumberKey=Clé RIB +## filters +FilterableFields=Champs Filtrables +FilteredFields=Champs Filtrés +FilteredFieldsValues=Valeurs de filtrages \ No newline at end of file diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index d7c2b04cd6c..abbd3d61307 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -115,7 +115,7 @@ VolumeUnitinch3=pouce3 VolumeUnitounce=once VolumeUnitlitre=litre VolumeUnitgallon=gallon -Size=taille +Size=Taille SizeUnitm=m SizeUnitdm=dm SizeUnitcm=cm