diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index caab3dcc3a6..0c5722ac0a7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -120,11 +120,11 @@ class ActionComm extends CommonObject if (empty($this->punctual)) $this->punctual = 0; if ($this->percentage > 100) $this->percentage = 100; if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if ($this->datep && $this->datef) $this->durationp=($this->datef - $this->datep); - if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date); - if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef=$this->datep; - if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; - if ($this->fk_project < 0) $this->fk_project = 0; + if (! empty($this->datep) && ! empty($this->datef)) $this->durationp=($this->datef - $this->datep); + if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); + if (! empty($this->datep) && ! empty($this->datef) && $this->datep > $this->datef) $this->datef=$this->datep; + if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; + if (! isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; if ($this->elementtype=='facture') $this->elementtype='invoice'; if ($this->elementtype=='commande') $this->elementtype='order'; if ($this->elementtype=='contrat') $this->elementtype='contract'; @@ -186,19 +186,19 @@ class ActionComm extends CommonObject $sql.= (strval($this->datef)!=''?"'".$this->db->idate($this->datef)."'":"null").","; //$sql.= (strval($this->date)!=''?"'".$this->db->idate($this->date)."'":"null").","; //$sql.= (strval($this->dateend)!=''?"'".$this->db->idate($this->dateend)."'":"null").","; - $sql.= ($this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").","; + $sql.= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").","; //$sql.= ($this->durationa >= 0 && $this->durationa != ''?"'".$this->durationa."'":"null").","; $sql.= " '".$this->type_id."',"; - $sql.= ($this->societe->id>0?" '".$this->societe->id."'":"null").","; - $sql.= ($this->fk_project>0?" '".$this->fk_project."'":"null").","; + $sql.= (isset($this->societe->id) && $this->societe->id > 0?" '".$this->societe->id."'":"null").","; + $sql.= (isset($this->fk_project) && $this->fk_project > 0?" '".$this->fk_project."'":"null").","; $sql.= " '".$this->db->escape($this->note)."',"; - $sql.= ($this->contact->id > 0?"'".$this->contact->id."'":"null").","; - $sql.= ($user->id > 0 ? "'".$user->id."'":"null").","; - $sql.= ($this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").","; - $sql.= ($this->userdone->id > 0?"'".$this->userdone->id."'":"null").","; + $sql.= (isset($this->contact->id) && $this->contact->id > 0?"'".$this->contact->id."'":"null").","; + $sql.= (isset($user->id) && $user->id > 0 ? "'".$user->id."'":"null").","; + $sql.= (isset($this->usertodo->id) && $this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").","; + $sql.= (isset($this->userdone->id) && $this->userdone->id > 0?"'".$this->userdone->id."'":"null").","; $sql.= "'".$this->db->escape($this->label)."','".$this->percentage."','".$this->priority."','".$this->fulldayevent."','".$this->db->escape($this->location)."','".$this->punctual."',"; - $sql.= ($this->fk_element?$this->fk_element:"null").","; - $sql.= ($this->elementtype?"'".$this->elementtype."'":"null").","; + $sql.= (! empty($this->fk_element)?$this->fk_element:"null").","; + $sql.= (! empty($this->elementtype)?"'".$this->elementtype."'":"null").","; $sql.= $conf->entity; $sql.= ")"; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 04fc64cdc6b..d14eadca5b5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1688,7 +1688,7 @@ class Facture extends CommonInvoice $result=$this->client->set_as_client(); // Si active on decremente le produit principal et ses composants a la validation de facture - if ($this->type != 3 && $result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL) + if ($this->type != 3 && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 9a589a06fa6..4304437196a 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2010 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2007 Regis Houssin +/* Copyright (C) 2003-2005 Rodolphe Quiedeville + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * 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 @@ -50,11 +50,11 @@ abstract class CommonDocGenerator 'myuser_lastname'=>$user->lastname, 'myuser_firstname'=>$user->firstname, 'myuser_login'=>$user->login, - 'myuser_phone'=>$user->officephone, - 'myuser_fax'=>$user->officefax, + 'myuser_phone'=>$user->office_phone, + 'myuser_fax'=>$user->office_fax, 'myuser_mobile'=>$user->user_mobile, - 'myuser_email'=>$user->user_email, - 'myuser_web'=>$user->url + 'myuser_email'=>$user->email, + //'myuser_web'=>$user->url // FIXME url not exist in $user object ); } diff --git a/htdocs/core/lib/doc.lib.php b/htdocs/core/lib/doc.lib.php index d6da55569ca..bc5cd90951b 100644 --- a/htdocs/core/lib/doc.lib.php +++ b/htdocs/core/lib/doc.lib.php @@ -1,10 +1,10 @@ - * Copyright (C) 2006 Rodolphe Quiedeville - * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2010-2011 Regis Houssin - * Copyright (C) 2010 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel +/* Copyright (C) 2006-2011 Laurent Destailleur + * Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel * * 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 @@ -43,10 +43,10 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli global $db, $conf, $langs; $idprod=$line->fk_product; - $label=$line->label; if (empty($label)) $label=$line->libelle; - $desc=$line->desc; if (empty($desc)) $desc=$line->description; - $ref_supplier=$line->ref_supplier; if (empty($ref_supplier)) $ref_supplier=$line->ref_fourn; // TODO Not yet saved for supplier invoices, only supplier orders - $note=$line->note; + $label=(! empty($line->label)?$line->label:(! empty($line->libelle)?$line->libelle:'')); + $desc=(! empty($line->desc)?$line->desc:(! empty($line->description)?$line->description:'')); + $ref_supplier=(! empty($line->ref_supplier)?$line->ref_supplier:(! empty($line->ref_fourn)?$line->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders + $note=(! empty($line->note)?$line->note:''); if ($issupplierline) $prodser = new ProductFournisseur($db); else $prodser = new Product($db); @@ -55,7 +55,7 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated - if ($conf->global->MAIN_MULTILANGS && ($outputlangs->defaultlang != $langs->defaultlang)) + if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; @@ -89,7 +89,8 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli { if ($idprod) { - if ( empty($hidedesc) ) $libelleproduitservice.=$desc; + if (empty($hidedesc)) + $libelleproduitservice.=$desc; } else { @@ -106,9 +107,9 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli { $prefix_prodserv = ""; $ref_prodserv = ""; - if ($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS) // In standard mode, we do not show this + if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this { - if($prodser->isservice()) + if ($prodser->isservice()) { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; } @@ -118,7 +119,7 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli } } - if ( empty($hideref) ) + if (empty($hideref)) { if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref else $ref_prodserv = $prodser->ref; // Show local ref only @@ -130,7 +131,7 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli } } - if ($line->date_start || $line->date_end) + if (! empty($line->date_start) || ! empty($line->date_end)) { $format='day'; // Show duration if exists diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index a40fddc9ef6..f650e4bd84f 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -246,4 +246,4 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs) return -1; } } -?> \ No newline at end of file +?> diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index e04c9b5c759..d796fee8441 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2010-2012 Laurent Destailleur + * Copyright (C) 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 @@ -108,12 +109,12 @@ class doc_generic_invoice_odt extends ModelePDFFactures 'object_ref'=>$object->ref, 'object_ref_ext'=>$object->ref_ext, 'object_ref_customer'=>$object->ref_client, - 'object_ref_supplier'=>$object->ref_fournisseur, + 'object_ref_supplier'=>(! empty($object->ref_fournisseur)?$object->ref_fournisseur:''), 'object_source_invoice_ref'=>$invoice_source->ref, 'object_date'=>dol_print_date($object->date,'day'), 'object_date_limit'=>dol_print_date($object->date_lim_reglement,'day'), 'object_date_creation'=>dol_print_date($object->date_creation,'day'), - 'object_date_modification'=>dol_print_date($object->date_modification,'day'), + 'object_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), 'object_payment_mode_code'=>$object->mode_reglement_code, 'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement), @@ -122,7 +123,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures 'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs), 'object_total_ttc'=>price($object->total_ttc,0,$outputlangs), - 'object_vatrate'=>vatrate($object->tva), + 'object_vatrate'=>(isset($object->tva)?vatrate($object->tva):''), 'object_note_private'=>$object->note, 'object_note'=>$object->note_public, // Payments @@ -339,7 +340,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat + '__TOTAL_VAT__' => $object->total_tva ); complete_substitutions_array($substitutionarray, $langs, $object); diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 783f9f053dd..dce9949a47c 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -1,6 +1,6 @@ - * Copyright (C) 2009-2010 Regis Houssin +/* Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2009-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 @@ -95,21 +95,23 @@ class ImportCsv extends ModeleImports } /** - * getDriverLabel + * getDriverLabel * - * @return string Label + * @param string $key Key + * @return string Label */ - function getDriverLabel() + function getDriverLabel($key='') { return $this->label; } /** - * getDriverDesc + * getDriverDesc * - * @return string Description + * @param string $key Key + * @return string Description */ - function getDriverDesc() + function getDriverDesc($key='') { return $this->desc; } @@ -125,21 +127,23 @@ class ImportCsv extends ModeleImports } /** - * getDriverVersion + * getDriverVersion * - * @return string Driver version + * @param string $key Key + * @return string Driver version */ - function getDriverVersion() + function getDriverVersion($key='') { return $this->version; } /** - * getDriverLabel + * getDriverLabel * - * @return string Label of external lib + * @param string $key Key + * @return string Label of external lib */ - function getLibLabel() + function getLibLabel($key='') { return $this->label_lib; } @@ -147,9 +151,10 @@ class ImportCsv extends ModeleImports /** * getLibVersion * - * @return string Version of external lib + * @param string $key Key + * @return string Version of external lib */ - function getLibVersion() + function getLibVersion($key='') { return $this->version_lib; } diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index eda1702da5b..ba4c61555a4 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2007 Regis Houssin +/* Copyright (C) 2005-2012 Laurent Destailleur + * 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