From ad095d7fb24752c60085f54c44ce9604545970bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 14:26:51 +0200 Subject: [PATCH 1/5] NEW Can set margins of PDFs --- htdocs/admin/pdf.php | 45 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index b0c32a344ff..2e650c75696 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -42,15 +42,25 @@ $langs->load("members"); if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); +$cancel = GETPOST('cancel','alpha'); + /* * Actions */ +if ($cancel) { + $action=''; +} + if ($action == 'update') { dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity); - + + dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", $_POST["MAIN_PDF_MARGIN_LEFT"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", $_POST["MAIN_PDF_MARGIN_RIGHT"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", $_POST["MAIN_PDF_MARGIN_TOP"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", $_POST["MAIN_PDF_MARGIN_BOTTOM"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity); @@ -133,7 +143,20 @@ if ($action == 'edit') // Edit print $formadmin->select_paper_format($selected,'MAIN_PDF_FORMAT'); print ''; - print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_LEFT").''; + print ''; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_RIGHT").''; + print ''; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_TOP").''; + print ''; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").''; + print ''; + print ''; + + print ''; print '
'; @@ -270,7 +293,9 @@ if ($action == 'edit') // Edit print ''; print '
'; - print ''; + print ''; + print '   '; + print ''; print '
'; print ''; @@ -314,6 +339,20 @@ else // Show print $pdfformatlabel; print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_LEFT").''; + print empty($conf->global->MAIN_PDF_MARGIN_LEFT)?10:$conf->global->MAIN_PDF_MARGIN_LEFT; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_RIGHT").''; + print empty($conf->global->MAIN_PDF_MARGIN_RIGHT)?10:$conf->global->MAIN_PDF_MARGIN_RIGHT; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_TOP").''; + print empty($conf->global->MAIN_PDF_MARGIN_TOP)?10:$conf->global->MAIN_PDF_MARGIN_TOP; + print ''; + print ''.$langs->trans("MAIN_PDF_MARGIN_BOTTOM").''; + print empty($conf->global->MAIN_PDF_MARGIN_BOTTOM)?10:$conf->global->MAIN_PDF_MARGIN_BOTTOM; + print ''; + + print ''; print '
'; From c673d283e01e41a6292875dce4b9a8bb07bcf817 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 18:21:50 +0200 Subject: [PATCH 2/5] Fix script to send emailings --- ...terface_50_modAgenda_ActionsAuto.class.php | 2 +- scripts/emailings/mailing-send.php | 41 ++++++++++++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index bce6d69b2fa..9da1ada59ad 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -48,7 +48,7 @@ class InterfaceActionsAuto extends DolibarrTriggers * $object->actionmsg (note, long text) * $object->actionmsg2 (label, short text) * $object->sendtoid (id of contact or array of ids) - * $object->socid + * $object->socid (id of thirdparty) * $object->fk_project * $object->fk_element * $object->elementtype diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 27cc22448e6..6465e765cfe 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -41,11 +41,12 @@ if (! isset($argv[1]) || ! $argv[1]) { exit(-1); } $id=$argv[1]; -if (! isset($argv[2]) || !empty($argv[2])) $login = $argv[2]; +if (isset($argv[2]) || !empty($argv[2])) $login = $argv[2]; else $login = ''; require_once ($path."../../htdocs/master.inc.php"); require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"); +require_once (DOL_DOCUMENT_ROOT."/comm/mailing/class/mailing.class.php"); // Global variables @@ -70,9 +71,8 @@ $user = new User($db); // for signature, we use user send as parameter if (! empty($login)) $user->fetch('',$login); -// We get list of emailing to process -$sql = "SELECT m.rowid, m.titre, m.sujet, m.body,"; -$sql.= " m.email_from, m.email_replyto, m.email_errorsto"; +// We get list of emailing id to process +$sql = "SELECT m.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql.= " WHERE m.statut IN (1,2)"; if ($id != 'all') @@ -96,12 +96,15 @@ if ($resql) dol_syslog("Process mailing with id ".$obj->rowid); print "Process mailing with id ".$obj->rowid."\n"; - $id = $obj->rowid; - $subject = $obj->sujet; - $message = $obj->body; - $from = $obj->email_from; - $replyto = $obj->email_replyto; - $errorsto = $obj->email_errorsto; + $emailing = new Mailing($db); + $emailing->fetch($obj->rowid); + + $id = $emailing->id; + $subject = $emailing->sujet; + $message = $emailing->body; + $from = $emailing->email_from; + $replyto = $emailing->email_replyto; + $errorsto = $emailing->email_errorsto; // Le message est-il en html $msgishtml=-1; // Unknown by default if (preg_match('/[\s\t]*/i',$message)) $msgishtml=1; @@ -232,6 +235,24 @@ if ($resql) dol_syslog("ok for emailing id ".$id." #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); + // Note: If emailing is 100 000 targets, 100 000 entries are added, so we don't enter events for each target here + // We must union table llx_mailing_taget for event tab OR enter 1 event with a special table link (id of email in event) + // Run trigger + /* + if ($obj2->source_type == 'contact') + { + $emailing->sendtoid = $obj2->source_id; + } + if ($obj2->source_type == 'thirdparty') + { + $emailing->socid = $obj2->source_id; + } + // Call trigger + $result=$emailing->call_trigger('EMAILING_SENTBYMAIL',$user); + if ($result < 0) $error++; + // End call triggers + */ + $sqlok ="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sqlok.=" SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj2->rowid; $resqlok=$db->query($sqlok); From 0bc46facd75af8117780da5e4b30af9011645bd1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 21:24:18 +0200 Subject: [PATCH 3/5] Add missing vat_src_code on recurring invoices --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_facture_rec.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 71f9a17273c..991381cb432 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -141,6 +141,8 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_soc_remise_fk_invoice_su ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid); ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier_source FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid); +ALTER TABLE llx_facture_rec ADD COLUMN vat_src_code varchar(10) DEFAULT ''; + UPDATE llx_const set value='moono-lisa' where value = 'moono' AND name = 'FCKEDITOR_SKIN'; ALTER TABLE llx_product_price ADD COLUMN default_vat_code varchar(10) after tva_tx; diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql index d0d79ef57dc..0e25100386b 100644 --- a/htdocs/install/mysql/tables/llx_facture_rec.sql +++ b/htdocs/install/mysql/tables/llx_facture_rec.sql @@ -32,6 +32,7 @@ create table llx_facture_rec remise_percent real DEFAULT 0, remise_absolue real DEFAULT 0, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva double(24,8) DEFAULT 0, localtax1 double(24,8) DEFAULT 0, -- amount localtax1 localtax2 double(24,8) DEFAULT 0, -- amount localtax2 From b8f5e93ab0b56157dbfa83d95da42df84ff57487 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 21:40:18 +0200 Subject: [PATCH 4/5] Debug inventory data model --- htdocs/install/mysql/data/llx_c_tva.sql | 2 +- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 13 +++++++++---- htdocs/install/mysql/tables/llx_inventorydet.sql | 8 ++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 34842ed324e..3b401abd37d 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -96,11 +96,11 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (80 -- FRANCE (id country=1) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 11, 1, '20','0','VAT standard rate (France hors DOM-TOM)',1); -insert into llx_c_tva(rowid,fk_pays,taux,code,recuperableonly,note,active) values ( 12, 1, '8.5', '8.5', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 14, 1, '5.5','0','VAT reduced rate (France hors DOM-TOM)',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 15, 1, '0','0','VAT Rate 0 ou non applicable',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 16, 1, '2.1','0','VAT super-reduced rate',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 17, 1, '10','0','VAT reduced rate',1); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 991381cb432..1982ef6aff8 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -229,9 +229,9 @@ fk_inventory integer DEFAULT 0, fk_warehouse integer DEFAULT 0, fk_product integer DEFAULT 0, batch varchar(30) DEFAULT NULL, -qty_view double DEFAULT 0, -qty_stock double DEFAULT 0, -qty_regulated double DEFAULT 0, +qty_view double DEFAULT NULL, +qty_stock double DEFAULT NULL, +qty_regulated double DEFAULT NULL, pmp double DEFAULT 0, pa double DEFAULT 0, new_pmp double DEFAULT 0 @@ -242,4 +242,9 @@ ALTER TABLE llx_inventory ADD INDEX idx_inventory_tms (tms); ALTER TABLE llx_inventory ADD INDEX idx_inventory_datec (datec); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_tms (tms); ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_datec (datec); -ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory); \ No newline at end of file +ALTER TABLE llx_inventorydet ADD INDEX idx_inventorydet_fk_inventory (fk_inventory); + +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85', '0','VAT standard rate (DOM sauf Guyane et Saint-Martin)',0); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,note,active) values (1, '8.5', '85NPR', '1','VAT standard rate (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par acheteur',0); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,note,active) values (1, '8.5', '85NPROM', '1', 2, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer',0); +insert into llx_c_tva(fk_pays,taux,code,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (1, '8.5', '85NPROMOMR', '1', 2, 3, 2.5, 3, 'VAT standard rate (DOM sauf Guyane et Saint-Martin), NPR, Octroi de Mer et Octroi de Mer Regional',0); diff --git a/htdocs/install/mysql/tables/llx_inventorydet.sql b/htdocs/install/mysql/tables/llx_inventorydet.sql index 2b203e0c58b..ce40d03939c 100644 --- a/htdocs/install/mysql/tables/llx_inventorydet.sql +++ b/htdocs/install/mysql/tables/llx_inventorydet.sql @@ -25,10 +25,10 @@ tms timestamp, fk_inventory integer DEFAULT 0, fk_warehouse integer DEFAULT 0, fk_product integer DEFAULT 0, -batch varchar(30) DEFAULT NULL, -- Lot or serial number -qty_view double DEFAULT 0, -qty_stock double DEFAULT 0, -qty_regulated double DEFAULT 0, +batch varchar(30) DEFAULT NULL, -- Lot or serial number +qty_view double DEFAULT NULL, -- must be filled once regulation is done +qty_stock double DEFAULT NULL, -- can be filled during draft edition +qty_regulated double DEFAULT NULL, -- must be filled once regulation is done pmp double DEFAULT 0, pa double DEFAULT 0, new_pmp double DEFAULT 0 From a115d4877b9903dfb137e9ecb2d0cd2fb03db4c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 22:37:23 +0200 Subject: [PATCH 5/5] Fix for new property array fields --- htdocs/api/class/api.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 7aef2671c8d..9228c71ccbf 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -90,6 +90,8 @@ class DolibarrApi // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses unset($object->linkedObjects); + unset($object->fields); + unset($object->oldline); unset($object->error);