From 0d308f74be0fafdbaba332d0f448c583c2b2bf2e Mon Sep 17 00:00:00 2001 From: Andreas Pachler Date: Thu, 24 Mar 2016 09:16:24 +0100 Subject: [PATCH 01/26] Added functionality to get project customer contact as contact_xx tags --- .../doc/doc_generic_project_odt.modules.php | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index d4ee4bacb80..b8dfa111446 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -482,7 +482,30 @@ class doc_generic_project_odt extends ModelePDFProjects dol_mkdir($conf->projet->dir_temp); - $socobject=$object->thirdparty; + // If PROJECTLEADER contact defined on project, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external','PROJECTLEADER'); + if (count($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + if (! empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + else { + $socobject = $object->thirdparty; + // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } + } + else + { + $socobject=$object->thirdparty; + } // Make substitution $substitutionarray=array( @@ -527,8 +550,12 @@ class doc_generic_project_odt extends ModelePDFProjects $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in project as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); + $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); From a67b9afb6cef17f01c5e98dbfa84d8265a21a7e7 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 28 Mar 2016 21:31:23 +0200 Subject: [PATCH 02/26] FIX: Add informations to show & correct problems to export in bookkeeping --- .../accountancy/journal/purchasesjournal.php | 28 ++++++--- htdocs/accountancy/journal/sellsjournal.php | 59 ++++++++++++------- 2 files changed, 59 insertions(+), 28 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 82811598188..e89a0f94a34 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -1,4 +1,4 @@ - * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent @@ -90,7 +90,7 @@ $sql .= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_cod $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0 "; @@ -164,6 +164,19 @@ if ($action == 'writebookkeeping') { $error = 0; foreach ( $tabfac as $key => $val ) { + + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $invoicestatic->ref = $val["refsologest"]; + $invoicestatic->refsupplier = $val["refsuppliersologest"]; + $invoicestatic->type = $val["type"]; + $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32)); + + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + + foreach ( $tabttc[$key] as $k => $mt ) { // get compte id and label @@ -175,7 +188,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; - $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; @@ -193,6 +206,8 @@ if ($action == 'writebookkeeping') { // Product / Service foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k); if ($mt) { // get compte id and label $accountingaccount = new AccountingAccount($db); @@ -205,7 +220,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->refsupplier . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -236,7 +251,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = $langs->trans("VAT"); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->refsupplier .' - '. $langs->trans("VAT"); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -248,7 +263,7 @@ if ($action == 'writebookkeeping') { $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -517,5 +532,4 @@ if ($action == 'export_csv') { // End of page llxFooter(); } - $db->close(); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 670875ec52b..ff3ccf9dc6d 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -1,4 +1,4 @@ - * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent @@ -24,9 +24,9 @@ */ /** - * \file htdocs/accountancy/journal/sellsjournal.php - * \ingroup Advanced accountancy - * \brief Page with sells journal + * \file htdocs/accountancy/journal/sellsjournal.php + * \ingroup Advanced accountancy + * \brief Page with sells journal */ require '../../main.inc.php'; @@ -142,15 +142,14 @@ if ($result) { // Situation invoices handling $line = new FactureLigne($db); - $line->fetch($obj->fdid); // id of line - $prev_progress = 0; + $line->fetch($obj->rowid); + $prev_progress = $line->get_prev_progress(); if ($obj->type == Facture::TYPE_SITUATION) { - // Avoid divide by 0 + // Avoid divide by 0 if ($obj->situation_percent == 0) { $situation_ratio = 0; } else { - $prev_progress = $line->get_prev_progress($obj->rowid); // id of invoice - $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; + $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; } } else { $situation_ratio = 1; @@ -194,6 +193,14 @@ if ($action == 'writebookkeeping') { $error = 0; foreach ( $tabfac as $key => $val ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; + +$invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + + foreach ( $tabttc[$key] as $k => $mt ) { $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; @@ -204,7 +211,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - $bookkeeping->label_compte = $tabcompany[$key]['name']; + //$bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -234,7 +242,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $accountingaccount->label; + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -264,7 +272,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $langs->trans("VAT"); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -275,7 +283,7 @@ if ($action == 'writebookkeeping') { $result = $bookkeeping->create($user); if ($result < 0) { $error ++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -305,6 +313,9 @@ if ($action == 'export_csv') { $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; +$invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); foreach ( $tabttc[$key] as $k => $mt ) { @@ -314,7 +325,8 @@ if ($action == 'export_csv') { print length_accounta(html_entity_decode($k)) . $sep; print ($mt < 0 ? 'C' : 'D') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print utf8_decode($companystatic->name) . $sep; + print utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; + //print utf8_decode($companystatic->name) . $sep; print $val["ref"]; print "\n"; } @@ -329,7 +341,8 @@ if ($action == 'export_csv') { print $sep; print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print dol_trunc($accountingaccount_static->label, 32) . $sep; + print utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount_static->label)) . $sep; + //print dol_trunc($accountingaccount_static->label, 32) . $sep; print $val["ref"]; print "\n"; } @@ -344,7 +357,8 @@ if ($action == 'export_csv') { print $sep; print ($mt < 0 ? 'D' : 'C') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print $langs->trans("VAT") . $sep; + print utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . $sep; + //print $langs->trans("VAT") . $sep; print $val["ref"]; print "\n"; } @@ -356,6 +370,9 @@ if ($action == 'export_csv') { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; $companystatic->client = $tabcompany[$key]['code_client']; + + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; $date = dol_print_date($db->jdate($val["date"]), 'day'); @@ -363,7 +380,7 @@ if ($action == 'export_csv') { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $companystatic->ref_client . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; //print '"' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; @@ -393,7 +410,7 @@ if ($action == 'export_csv') { print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - '. $langs->trans("VAT") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . '"' . $sep; //print '"' . $langs->trans("VAT") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; @@ -481,7 +498,7 @@ if ($action == 'export_csv') { print "" . length_accounta($k); //print "" . $langs->trans("ThirdParty"); //print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; - print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref_client . ' - ' . $langs->trans("Code_tiers"). ""; + print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"). ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; print "" . ($mt < 0 ? price(- $mt) : '') . ""; } @@ -498,7 +515,7 @@ if ($action == 'export_csv') { print "" . $invoicestatic->getNomUrl(1) . ""; print "" . length_accountg($k) . ""; //print "" . $accountingaccount->label . ""; - print "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref_client . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)) . ""; + print "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)) . ""; print "" . ($mt < 0 ? price(- $mt) : '') . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; print ""; @@ -512,7 +529,7 @@ if ($action == 'export_csv') { print "" . $date . ""; print "" . $invoicestatic->getNomUrl(1) . ""; print "" . length_accountg($k) . ""; - print "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref_client .' - '. $langs->trans("VAT") . ""; + print "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . ""; //print "" . $langs->trans("VAT") . ""; print "" . ($mt < 0 ? price(- $mt) : '') . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; From a1d95e11edde478b251c4ecd646c920df00e5c54 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 28 Mar 2016 21:33:49 +0200 Subject: [PATCH 03/26] Correct table --- htdocs/accountancy/journal/purchasesjournal.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index e89a0f94a34..d269dd88e57 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -4,7 +4,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013-2015 Alexandre Spangaro - * Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -90,7 +90,7 @@ $sql .= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_cod $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0 "; From 29c4971d5afe5bee5ce3bbd692f13756cf4d5e7a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 29 Mar 2016 21:14:19 +0200 Subject: [PATCH 04/26] Try to correct travis --- htdocs/accountancy/journal/purchasesjournal.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index d269dd88e57..6f157f0619a 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -220,7 +220,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_facturefourndet"]; $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->refsupplier . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->refsupplier . ' - ' . utf8_decode($accountingaccount->label); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index ff3ccf9dc6d..f26da69f243 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -242,7 +242,7 @@ $invoicestatic->id = $key; $bookkeeping->fk_docdet = $val["fk_facturedet"]; $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)); + $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode($accountingaccount->label); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; From f6f7dc8e86183c03a234fd5540f5536e63b11c12 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 30 Mar 2016 05:41:44 +0200 Subject: [PATCH 05/26] Try to correct travis II --- htdocs/accountancy/journal/purchasesjournal.php | 4 ++-- htdocs/accountancy/journal/sellsjournal.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 6f157f0619a..62309dc222e 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -1,4 +1,4 @@ - * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent @@ -123,7 +123,7 @@ if ($result) { $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); - // contrôles + // contrôles $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; $compta_prod = $obj->compte; if (empty($compta_prod)) { diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index f26da69f243..a88d60b8376 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -1,4 +1,4 @@ - * Copyright (C) 2007-2010 Jean Heimburger * Copyright (C) 2011 Juanjo Menent @@ -7,7 +7,7 @@ * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2014 Raphaël Doursenaud * * 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 From 7eded39e2803f4070ff50e355f56f54b420049f0 Mon Sep 17 00:00:00 2001 From: Andreas Pachler Date: Wed, 30 Mar 2016 08:34:32 +0200 Subject: [PATCH 06/26] Reworked functionality to get project contact as contact_xx tags --- .../doc/doc_generic_project_odt.modules.php | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index b8dfa111446..8b06239c996 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -494,19 +494,12 @@ class doc_generic_project_odt extends ModelePDFProjects // Recipient name if (! empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { - $socobject = $object->thirdparty; - // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; - } - } - else - { - $socobject=$object->thirdparty; + // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; } + $socobject=$object->thirdparty; + // Make substitution $substitutionarray=array( '__FROM_NAME__' => $this->emetteur->name, @@ -551,11 +544,11 @@ class doc_generic_project_odt extends ModelePDFProjects $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in project as contact_xxx tags - $array_thirdparty_contact = array(); + $array_project_contact = array(); if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); + $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); From 98ef17930707be7a5f653eb7713494e15c4aeb28 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 30 Mar 2016 21:09:27 +0200 Subject: [PATCH 07/26] Add contact hook I use the same hook name as contactpl --- htdocs/projet/tasks/contact.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 0faf21c1cc2..f3f58c17119 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -492,6 +492,13 @@ if ($id > 0 || ! empty($ref)) } } +if (is_object($hookmanager)) +{ + $hookmanager->initHooks(array('contacttpl')); + $parameters=array(); + $reshook=$hookmanager->executeHooks('formContactTpl',$parameters,$object,$action); +} + llxFooter(); From b018500fd4b85609714fc03ed38f8a386df18dd1 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 31 Mar 2016 14:37:06 +0200 Subject: [PATCH 08/26] FIX multicompany project access --- htdocs/projet/class/task.class.php | 4 ++-- htdocs/projet/contact.php | 2 +- htdocs/projet/document.php | 2 +- htdocs/projet/element.php | 2 +- htdocs/projet/ganttview.php | 2 +- htdocs/projet/note.php | 2 +- htdocs/projet/tasks.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index ca8ed73e10d..6ffb876bb7c 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -586,7 +586,7 @@ class Task extends CommonObject $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec2"; $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('project',1).")"; $sql.= " AND t.fk_projet = p.rowid"; } elseif ($mode == 1) @@ -607,7 +607,7 @@ class Task extends CommonObject { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; } - $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " WHERE p.entity IN (".getEntity('project',1).")"; } else return 'BadValueForParameterMode'; diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index ebfad425cf8..3ef4f777124 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -47,7 +47,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu // Security check $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; -$result = restrictedArea($user, 'projet', $id); +$result = restrictedArea($user, 'projet', $id,'projet&project'); /* diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index ce033f0e193..3834a6e7f6a 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -43,7 +43,7 @@ $mine = (GETPOST('mode','alpha') == 'mine' ? 1 : 0); // Security check $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; -$result=restrictedArea($user,'projet',$id,''); +$result=restrictedArea($user,'projet',$id,'projet&project'); $object = new Project($db); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 3839a9b0b06..d10c7f2441f 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -92,7 +92,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu // Security check $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; -$result = restrictedArea($user, 'projet', $projectid); +$result = restrictedArea($user, 'projet', $projectid, 'projet&project'); /* diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 091059d76e3..822489b643a 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -44,7 +44,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu // Security check $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; -$result = restrictedArea($user, 'projet', $id); +$result = restrictedArea($user, 'projet', $id,'projet&project'); $langs->load("users"); $langs->load("projects"); diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 45c4cffd65b..47423491930 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -42,7 +42,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu // Security check $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; -$result = restrictedArea($user, 'projet', $id); +$result = restrictedArea($user, 'projet', $id,'projet&project'); $permissionnote=$user->rights->projet->creer; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index eb95fd33624..648871be6db 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -61,7 +61,7 @@ $extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->tab // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; -$result = restrictedArea($user, 'projet', $id); +$result = restrictedArea($user, 'projet', $id,'projet&project'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('projecttaskcard','globalcard')); From 84d326e03612cae4c36e95bae38e48de3829892d Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 1 Apr 2016 06:41:49 +0200 Subject: [PATCH 09/26] FIX: Problem with dolibarr installation/migration script. Range is a reserved name. --- htdocs/admin/dict.php | 47 ++----------------- .../core/class/html.formaccounting.class.php | 6 +-- .../install/mysql/migration/3.9.0-4.0.0.sql | 2 +- .../tables/llx_c_accounting_category.sql | 2 +- 4 files changed, 10 insertions(+), 47 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d88df512b8c..a872f5b92ce 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -189,7 +189,7 @@ $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.new $tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; $tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; $tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, c.code as country_code, c.label as country, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_pays=c.rowid and c.active=1"; -$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range, a.position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; +$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; $tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department"; $tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; @@ -263,44 +263,7 @@ $tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country"; $tabfield[29]= "code,label,percent,position"; $tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; $tabfield[31]= "pcg_version,country_id,country,label"; -$tabfield[32]= "code,label,range,position,country_id,country"; -$tabfield[33]= "code,label"; -$tabfield[34]= "code,label"; - -// Nom des champs d'edition pour modification d'un enregistrement -$tabfieldvalue=array(); -$tabfieldvalue[1] = "code,libelle,country"; -$tabfieldvalue[2] = "code,libelle,region"; // "code,libelle,region" -$tabfieldvalue[3] = "code,libelle,country"; -$tabfieldvalue[4] = "code,label"; -$tabfieldvalue[5] = "code,label"; -$tabfieldvalue[6] = "code,libelle,type,color,position"; -$tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible"; -$tabfieldvalue[8] = "code,libelle,country".(! empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?',position':''); -$tabfieldvalue[9] = "code,label,unicode"; -$tabfieldvalue[10]= "country,code,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldvalue[11]= "element,source,code,libelle,position"; -$tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage,sortorder"; -$tabfieldvalue[13]= "code,libelle,type,accountancy_code"; -$tabfieldvalue[14]= "code,libelle,price,organization,country"; -$tabfieldvalue[15]= "code,libelle,width,height,unit"; -$tabfieldvalue[16]= "code,libelle,sortorder"; -$tabfieldvalue[17]= "code,label,accountancy_code"; -$tabfieldvalue[18]= "code,libelle,tracking"; -$tabfieldvalue[19]= "code,libelle"; -$tabfieldvalue[20]= "code,libelle"; -$tabfieldvalue[21]= "code,label"; -$tabfieldvalue[22]= "code,label"; -$tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note"; -$tabfieldvalue[24]= "code,label"; -$tabfieldvalue[25]= "label,type_template,position,topic,content"; -$tabfieldvalue[26]= "code,label,short_label"; -$tabfieldvalue[27]= "code,libelle"; -$tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country"; -$tabfieldvalue[29]= "code,label,percent,position"; -$tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; -$tabfieldvalue[31]= "pcg_version,country,label"; -$tabfieldvalue[32]= "code,label,range,position,country"; +$tabfield[32]= "code,label,range_account,position,country"; $tabfieldvalue[33]= "code,label"; $tabfieldvalue[34]= "code,label"; @@ -337,7 +300,7 @@ $tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country"; $tabfieldinsert[29]= "code,label,percent,position"; $tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; $tabfieldinsert[31]= "pcg_version,fk_pays,label"; -$tabfieldinsert[32]= "code,label,range,position,fk_country"; +$tabfieldinsert[32]= "code,label,range_account,position,fk_country"; $tabfieldinsert[33]= "code,label"; $tabfieldinsert[34]= "code,label"; @@ -998,7 +961,7 @@ if ($id) if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); } if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } - if ($fieldlist[$field]=='range') { $valuetoshow=$langs->trans("Range"); } + if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } if ($id == 2) // Special cas for state page { @@ -1166,7 +1129,7 @@ if ($id) if ($fieldlist[$field]=='sortorder') { $valuetoshow=$langs->trans("SortOrder"); } if ($fieldlist[$field]=='short_label') { $valuetoshow=$langs->trans("ShortLabel"); } if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } - if ($fieldlist[$field]=='range') { $valuetoshow=$langs->trans("Range"); } + if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } // Affiche nom du champ if ($showfield) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e8664e3166d..4a76cca81d6 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -64,7 +64,7 @@ class FormAccounting if (! empty($mysoc->country_id)) { - $sql = "SELECT c.rowid, c.label as type, c.range"; + $sql = "SELECT c.rowid, c.label as type, c.range_account"; $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; $sql.= " WHERE c.active = 1"; $sql.= " AND c.fk_country = ".$mysoc->country_id; @@ -72,7 +72,7 @@ class FormAccounting } else { - $sql = "SELECT c.rowid, c.label as type, c.range"; + $sql = "SELECT c.rowid, c.label as type, c.range_account"; $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; $sql.= " WHERE c.active = 1 AND c.fk_country = co.rowid"; $sql.= " AND co.code = '".$mysoc->country_code."'"; @@ -96,7 +96,7 @@ class FormAccounting print '