diff --git a/COPYRIGHT b/COPYRIGHT index c69dfc91d54..db0cb532478 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -60,6 +60,7 @@ Copyright (C) 2013 - Regis Houssin - Maxime Kohlhaas - Juanjo Menent +- Adolfo Segura Copyright (C) 2012 - Christophe Battarel diff --git a/ChangeLog b/ChangeLog index 42fa4ba9c23..a68df7ea1b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -170,6 +170,8 @@ Fix: [ bug #1075 ] POS module doesn't decrement stock of products in delayed pay Fix: [ bug #1171 ] Documents lost in interventions after validating Fix: fix unsubscribe URL into mailing when sending manually (not by script) Fix: [ bug #1182 ] ODT company_country tag is htmlencoded +Fix: [ bug #1196 ] Product barcode search does not expect 13th digit on EAN13 type +Fix: [ bug #1202 ] Wrong amount in deposit % invoice from proposal ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 2837bef8ca0..3a541b94df6 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -71,6 +71,15 @@ if (! $ENV{"DESTIBETARC"} || ! $ENV{"DESTISTABLE"}) { print "Error: Missing environment variables.\n"; print "You must define the environment variable DESTIBETARC and DESTISTABLE to point to the\ndirectories where you want to save the generated packages.\n"; + print "Example: DESTIBETARC='/media/HDDATA1_LD/Mes Sites/Web/Dolibarr/dolibarr.org/files/lastbuild'\n"; + print "Example: DESTISTABLE='/media/HDDATA1_LD/Mes Sites/Web/Dolibarr/dolibarr.org/files/stable'\n"; + print "$PROG.$Extension aborted.\n"; + sleep 2; + exit 1; +} +if (! -d $ENV{"DESTIBETARC"} || ! -d $ENV{"DESTISTABLE"}) +{ + print "Error: Directory of environment variable DESTIBETARC or DESTISTABLE does not exist.\n"; print "$PROG.$Extension aborted.\n"; sleep 2; exit 1; @@ -405,6 +414,7 @@ if ($nboftargetok) { if ($target eq 'TGZ') { $NEWDESTI=$DESTI; + mkdir($DESTI.'/standard'); if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } print "Remove target $FILENAMETGZ.tgz...\n"; @@ -431,6 +441,7 @@ if ($nboftargetok) { if ($target eq 'XZ') { $NEWDESTI=$DESTI; + mkdir($DESTI.'/standard'); if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } print "Remove target $FILENAMEXZ.xz...\n"; @@ -461,6 +472,7 @@ if ($nboftargetok) { if ($target eq 'ZIP') { $NEWDESTI=$DESTI; + mkdir($DESTI.'/standard'); if (-d $DESTI.'/standard') { $NEWDESTI=$DESTI.'/standard'; } print "Remove target $FILENAMEZIP.zip...\n"; @@ -495,6 +507,7 @@ if ($nboftargetok) { if ($target =~ /FEDO/i) { $subdir="package_rpm_redhat-fedora"; } if ($target =~ /MAND/i) { $subdir="package_rpm_mandriva"; } if ($target =~ /OPEN/i) { $subdir="package_rpm_opensuse"; } + mkdir($DESTI.'/'.$subdir); if (-d $DESTI.'/'.$subdir) { $NEWDESTI=$DESTI.'/'.$subdir; } $ARCH='noarch'; @@ -591,6 +604,7 @@ if ($nboftargetok) { if ($target eq 'DEB') { $NEWDESTI=$DESTI; + mkdir($DESTI.'/package_debian-ubuntu'); if (-d $DESTI.'/package_debian-ubuntu') { $NEWDESTI=$DESTI.'/package_debian-ubuntu'; } $olddir=getcwd(); @@ -751,6 +765,7 @@ if ($nboftargetok) { if ($target eq 'APS') { $NEWDESTI=$DESTI; + mkdir($DESTI.'/package_aps'); if (-d $DESTI.'/package_aps') { $NEWDESTI=$DESTI.'/package_aps'; } $newbuild = $BUILD; @@ -835,6 +850,7 @@ if ($nboftargetok) { if ($target eq 'EXEDOLIWAMP') { $NEWDESTI=$DESTI; + mkdir($DESTI.'/package_windows'); if (-d $DESTI.'/package_windows') { $NEWDESTI=$DESTI.'/package_windows'; } print "Remove target $FILENAMEEXEDOLIWAMP.exe...\n"; diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index 1636246e536..4d8f0264e5f 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -2,6 +2,8 @@ /* Copyright (C) 2007-2008 Jeremie Ollivier * Copyright (C) 2008-2011 Laurent Destailleur * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2013 Marcos García + * Copyright (C) 2013 Adolfo Segura * * 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 @@ -37,7 +39,20 @@ if ( GETPOST('filtre') ) { $sql.= " AND p.tosell = 1"; if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0"; $sql.= " AND (p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'"; - if (! empty($conf->barcode->enabled)) $sql.= " OR p.barcode LIKE '%".$db->escape(GETPOST('filtre'))."%')"; + if (! empty($conf->barcode->enabled)) { + + $filtre = GETPOST('filtre'); + + //If the barcode looks like an EAN13 format and the last digit is included in it, + //then whe look for the 12-digit too + //As the twelve-digit string will also hit the 13-digit code, we only look for this one + if (strlen($filtre) == 13) { + $crit_12digit = substr($filtre, 0, 12); + $sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%')"; + } else { + $sql.= " OR p.barcode LIKE '%".$db->escape($filtre)."%')"; + } + } else $sql.= ")"; $sql.= " ORDER BY label"; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 6054270d002..044cc203cf8 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -903,7 +903,7 @@ else if ($action == 'add' && $user->rights->facture->creer) $numlines=count($lines); for ($i=0; $i<$numlines; $i++) { - $totalamount += $lines[$i]->subprice; + $totalamount += $lines[$i]->total_ht; } if ($totalamount!=0) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index dea0334dc13..e0741c26cef 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -404,7 +404,7 @@ class ImportCsv extends ModeleImports //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeid' || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref') { - if (! is_numeric($newval)) // If value into input import file is not a numeric, we apply the function defined into descriptor + if (! is_numeric($newval) && $newval != '') // If value into input import file is not a numeric, we apply the function defined into descriptor { $file=$objimport->array_import_convertvalue[0][$val]['classfile']; $class=$objimport->array_import_convertvalue[0][$val]['class']; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index a94e59b4e5f..a225af6e3da 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -250,10 +250,10 @@ class modFournisseur extends DolibarrModules $this->export_label[$r]='Factures fournisseurs et lignes de facture'; $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.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'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.ref'=>"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_public'=>"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_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'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.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'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_public'=>"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.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"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_public'=>"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_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"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_public'=>"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.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'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.ref'=>"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_public'=>"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_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"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_public'=>"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.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'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.ref'=>"invoice",'f.ref_supplier'=>"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_public'=>"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 $this->export_sql_start[$r]='SELECT DISTINCT '; @@ -269,10 +269,10 @@ class modFournisseur extends DolibarrModules $this->export_label[$r]='Factures fournisseurs et reglements'; $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.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'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.ref'=>"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_public'=>"InvoiceNote",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber'); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'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.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'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_public'=>"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.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"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_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number'); - $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"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_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.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'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.ref'=>"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_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment'); + $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"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_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.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'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.ref'=>"invoice",'f.ref_supplier'=>"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_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 $this->export_sql_start[$r]='SELECT DISTINCT '; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b855eddaa41..28d83897b37 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -417,7 +417,7 @@ class modSociete extends DolibarrModules $this->import_icon[$r]='contact'; $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','extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // 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.lastname'=>"Name*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"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_private'=>"Note",'s.note_public'=>"Note",'s.datec'=>"DateCreation"); + $this->import_fields_array[$r]=array('s.fk_soc'=>'ThirdPartyName','s.civilite'=>'UserTitle','s.lastname'=>"Lastname*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"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_private'=>"Note",'s.note_public'=>"Note",'s.datec'=>"DateCreation"); // Add extra fields $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity = ".$conf->entity; $resql=$this->db->query($sql); @@ -438,7 +438,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.zip'=>'75000','s.town'=>'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_private'=>"My private note",'s.note_public'=>"My public note"); + $this->import_examplevalues_array[$r]=array('s.fk_soc'=>'MyBigCompany','s.civilite'=>"MR",'s.lastname'=>"Smith",'s.firstname'=>'John','s.address'=>'61 jump street','s.zip'=>'75000','s.town'=>'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_private'=>"My private note",'s.note_public'=>"My public note"); // Import Bank Accounts $r++; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 396e5155818..7402272fe73 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -221,7 +221,7 @@ 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; + if ($object->date_echeance && $object->date_echeance < $object->date) $object->date_echeance=$object->date; $result=$object->update($user); if ($result < 0) dol_print_error($db,$object->error); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6a94184d7c1..065b3191bec 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2973,7 +2973,7 @@ class Product extends CommonObject // Objet $obj=array(); $obj['photo']=$photo; - if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) $obj['photo_vignette']=$photo_vignette; + if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) $obj['photo_vignette']=$dirthumb . $photo_vignette; else $obj['photo_vignette']=""; $tabobj[$nbphoto-1]=$obj; diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 30ed2fd95b1..e9fe0b60a03 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -2,12 +2,13 @@ /* Copyright (C) 2001-2006 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Marcos García + * Copyright (C) 2012-2013 Marcos García * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2013 Raphaël Doursenaud * Copyright (C) 2013 Jean Heimburger * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Adolfo segura * * 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 @@ -136,13 +137,14 @@ else $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; -// multilang + // multilang if ($conf->global->MAIN_MULTILANGS) // si l'option est active { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang() ."'"; } $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; - if ($sall) { + if ($sall) + { // For natural search $params = array('p.ref', 'p.label', 'p.description', 'p.note'); // multilang @@ -162,10 +164,8 @@ else if ($type == 1) $sql.= " AND p.fk_product_type = '1'"; else $sql.= " AND p.fk_product_type <> '1'"; } - if ($sref) { - $sql .= natural_search('p.ref', $sref); - } - if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'"; + if ($sref) $sql .= natural_search('p.ref', $sref); + if ($sbarcode) $sql .= natural_search('p.barcode', $sbarcode); if ($snom) { $params = array('p.label'); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index d0d28bf2cee..664be4b9a05 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -297,6 +297,25 @@ class Societe extends CommonObject } } + function create_individual($user) { + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + $contact=new Contact($this->db); + + $contact->name = $this->name_bis; + $contact->firstname = $this->firstname; + $contact->socid = $this->id; // fk_soc + $contact->statut = 1; + $contact->priv = 0; + $result = $contact->create($user); + if ($result < 0) { + $this->error = $contact->error; + $this->errors = $contact->errors; + dol_syslog("Societe::create_individual ERROR:" . $this->error, LOG_ERR); + } + + return $result; + } + /** * Check properties of third party are ok (like name, third party codes, ...) * @@ -994,6 +1013,8 @@ class Societe extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $entity=isset($this->entity)?$this->entity:$conf->entity; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $error = 0; @@ -1122,12 +1143,15 @@ class Societe extends CommonObject $this->db->commit(); // Delete directory - $docdir = $conf->societe->multidir_output[$this->entity] . "/" . $id; - if (file_exists($docdir)) + if (! empty($conf->societe->multidir_output[$entity])) { - dol_delete_dir_recursive($docdir); + $docdir = $conf->societe->multidir_output[$entity] . "/" . $id; + if (dol_is_dir($docdir)) + { + dol_delete_dir_recursive($docdir); + } } - + return 1; } else @@ -2862,7 +2886,9 @@ class Societe extends CommonObject $sql = "SELECT sum(total) as amount FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE fk_soc = ". $this->id; $sql .= " AND paye = 0"; - $sql .= " AND fk_statut <> 0"; + $sql .= " AND fk_statut <> 0"; // Not a draft + //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason + $sql .= " AND fk_statut <> 3"; // Not abandonned dol_syslog("get_OutstandingBill sql=".$sql); $resql=$this->db->query($sql); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 2fae97baa4f..c5ca713f9f5 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -255,28 +255,10 @@ if (empty($reshook)) if ($object->particulier) { dol_syslog("This thirdparty is a personal people",LOG_DEBUG); - $contact=new Contact($db); - - $contact->civilite_id = $object->civilite_id; - $contact->name = $object->name_bis; - $contact->firstname = $object->firstname; - $contact->address = $object->address; - $contact->zip = $object->zip; - $contact->town = $object->town; - $contact->state_id = $object->state_id; - $contact->country_id = $object->country_id; - $contact->socid = $object->id; // fk_soc - $contact->statut = 1; - $contact->email = $object->email; - $contact->skype = $object->skype; - $contact->phone_pro = $object->phone; - $contact->fax = $object->fax; - $contact->priv = 0; - - $result=$contact->create($user); + $result=$object->create_individual($user); if (! $result >= 0) { - $error=$contact->error; $errors=$contact->errors; + $error=$object->error; $errors=$object->errors; } } diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 8b3d4569dbf..f77af335e2e 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -637,7 +637,7 @@ function createOrder($authentication,$order) $newobject->date_lim_reglement=dol_stringtotime($order['date_due'],'dayrfc'); $newobject->note_private=$order['note_private']; $newobject->note_public=$order['note_public']; - $newobject->statut=$order['status']; + $newobject->statut=0; $newobject->facturee=$order['facturee']; $newobject->fk_project=$order['project_id']; $newobject->cond_reglement_id=$order['cond_reglement_id']; @@ -669,30 +669,36 @@ function createOrder($authentication,$order) $db->begin(); - - $result=$newobject->create($fuser,0,0); + dol_syslog("Webservice server_order:: order creation start", LOG_DEBUG); + $result=$newobject->create($fuser); + dol_syslog('Webservice server_order:: order creation done with $result='.$result, LOG_DEBUG); if ($result < 0) { + dol_syslog("Webservice server_order:: order creation failed", LOG_ERR); $error++; } - if ($newobject->statut == 1) // We want order validated + if ($order['status'] == 1) // We want order validated { - $result=$newobject->validate($fuser); + dol_syslog("Webservice server_order:: order validation start", LOG_DEBUG); + $result=$newobject->valid($fuser); if ($result < 0) { + dol_syslog("Webservice server_order:: order validation failed", LOG_ERR); $error++; } } - if (! $error) + if ($result >= 0) { + dol_syslog("Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG); $db->commit(); $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref); } else { + dol_syslog("Webservice server_order:: order creation or validation failed, rollback", LOG_ERR); $db->rollback(); $error++; $errorcode='KO'; diff --git a/htdocs/webservices/server_other.php b/htdocs/webservices/server_other.php index 81a15e5b771..193e01de2f2 100644 --- a/htdocs/webservices/server_other.php +++ b/htdocs/webservices/server_other.php @@ -224,7 +224,7 @@ function getDocument($authentication, $modulepart, $file, $refname='') if (empty($refname)) $refname=basename(dirname($original_file)."/"); // Security check - $check_access = dol_check_secure_access_document($modulepart,$original_file,$conf->entity,$refname,$fuser); + $check_access = dol_check_secure_access_document($modulepart,$original_file,$conf->entity,$fuser,$refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 152a28053fa..ccc05902dca 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -443,6 +443,7 @@ function createThirdParty($authentication,$thirdparty) $newobject->tva_intra=$thirdparty['vat_number']; $newobject->canvas=$thirdparty['canvas']; + $newobject->particulier=$thirdparty['individual']; //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels @@ -457,6 +458,11 @@ function createThirdParty($authentication,$thirdparty) $db->begin(); $result=$newobject->create($fuser); + if ($newobject->particulier && $result > 0) { + $newobject->firstname = $thirdparty['firstname']; + $newobject->name_bis = $thirdparty['ref']; + $result = $newobject->create_individual($fuser); + } if ($result <= 0) { $error++;