From 889c72611d258140c7d15b00144995c74e78aa20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 19 Mar 2016 23:00:33 +0100 Subject: [PATCH 01/78] NEW Created Account::__toString, Account::getFieldsToShow and Account::getAccountNumberOrder to refactor the way account number was shown --- htdocs/compta/bank/card.php | 223 +++++------------- htdocs/compta/bank/class/account.class.php | 102 ++++++++ htdocs/core/lib/pdf.lib.php | 96 +++----- .../class/companybankaccount.class.php | 87 ++----- htdocs/societe/rib.php | 147 +++--------- htdocs/user/bank.php | 147 +++--------- htdocs/user/class/userbankaccount.class.php | 87 ++----- 7 files changed, 295 insertions(+), 594 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index b33b0438552..defa0163891 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2014-2015 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Marcos García * * 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 @@ -387,65 +388,28 @@ if ($action == 'create') print ''; // Show fields of bank account - $fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey'; - if (! empty($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber'; - } - else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION; - } - $fieldlistsarray=explode(' ',$fieldlists); - - foreach($fieldlistsarray as $val) - { - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankCode").''; - print ''; - print ''; - } + foreach ($account->getFieldsToShow() as $val) { + if ($val == 'BankCode') { + $name = 'code_banque'; + $size = 8; + $content = $account->code_banque; + } elseif ($val == 'DeskCode') { + $name = 'code_guichet'; + $size = 8; + $content = $account->code_guichet; + } elseif ($val == 'BankAccountNumber') { + $name = 'number'; + $size = 18; + $content = $account->number; + } elseif ($val == 'BankAccountNumberKey') { + $name = 'cle_rib'; + $size = 3; + $content = $account->cle_rib; } - if ($val == 'DeskCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("DeskCode").''; - print ''; - print ''; - } - } - - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 2) - { - print ''.$langs->trans("BankCode").''; - print ''; - print ''; - } - } - - if ($val == 'AccountNumber') - { - print ''.$langs->trans("BankAccountNumber").''; - print ''; - print ''; - } - - if ($val == 'BankAccountNumberKey') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankAccountNumberKey").''; - print ''; - print ''; - } - } + print ''.$langs->trans($val).''; + print ''; + print ''; } $ibankey="IBANNumber"; $bickey="BICNumber"; @@ -651,64 +615,20 @@ else print ''.$account->bank.''; // Show fields of bank account - $fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey'; - if (! empty($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber'; - } - else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION; - } - $fieldlistsarray=explode(' ',$fieldlists); - - foreach($fieldlistsarray as $val) - { - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankCode").''; - print ''.$account->code_banque.''; - print ''; - } - } - if ($val == 'DeskCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("DeskCode").''; - print ''.$account->code_guichet.''; - print ''; - } + foreach ($account->getFieldsToShow() as $val) { + if ($val == 'BankCode') { + $content = $account->code_banque; + } elseif ($val == 'DeskCode') { + $content = $account->code_guichet; + } elseif ($val == 'BankAccountNumber') { + $content = $account->number; + } elseif ($val == 'BankAccountNumberKey') { + $content = $account->cle_rib; } - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 2) - { - print ''.$langs->trans("BankCode").''; - print ''.$account->code_banque.''; - print ''; - } - } - - if ($val == 'AccountNumber') - { - print ''.$langs->trans("BankAccountNumber").''; - print ''.$account->number.''; - print ''; - } - - if ($val == 'BankAccountNumberKey') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankAccountNumberKey").''; - print ''.$account->cle_rib.''; - print ''; - } - } + print ''.$langs->trans($val).''; + print ''.$content.''; + print ''; } $ibankey="IBANNumber"; @@ -939,65 +859,28 @@ else print ''; // Show fields of bank account - $fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey'; - if (! empty($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber'; - } - else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION; - } - $fieldlistsarray=explode(' ',$fieldlists); - - foreach($fieldlistsarray as $val) - { - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankCode").''; - print ''; - print ''; - } + foreach ($account->getFieldsToShow() as $val) { + if ($val == 'BankCode') { + $name = 'code_banque'; + $size = 8; + $content = $account->code_banque; + } elseif ($val == 'DeskCode') { + $name = 'code_guichet'; + $size = 8; + $content = $account->code_guichet; + } elseif ($val == 'BankAccountNumber') { + $name = 'number'; + $size = 18; + $content = $account->number; + } elseif ($val == 'BankAccountNumberKey') { + $name = 'cle_rib'; + $size = 3; + $content = $account->cle_rib; } - if ($val == 'DeskCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("DeskCode").''; - print ''; - print ''; - } - } - - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 2) - { - print ''.$langs->trans("BankCode").''; - print ''; - print ''; - } - } - - if ($val == 'AccountNumber') - { - print ''.$langs->trans("BankAccountNumber").''; - print ''; - print ''; - } - - if ($val == 'BankAccountNumberKey') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankAccountNumberKey").''; - print ''; - print ''; - } - } + print ''.$langs->trans($val).''; + print ''; + print ''; } $ibankey="IBANNumber"; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index bad817d7a21..123f4537a58 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -238,6 +238,31 @@ class Account extends CommonObject ); } + /** + * Shows the account number in the appropiate format + * + * @return string + */ + public function __toString() + { + $string = ''; + + foreach ($this->getFieldsToShow() as $val) { + + if ($val == 'BankCode') { + $string .= $this->code_banque.' '; + } elseif ($val == 'BankAccountNumber') { + $string .= $this->number.' '; + } elseif ($val == 'DeskCode') { + $string .= $this->code_guichet.' '; + } elseif ($val == 'BankAccountNumberKey') { + $string .= $this->cle_rib.' '; + } + } + + return trim($string); + } + /** * Return if a bank account need to be conciliated @@ -1230,6 +1255,83 @@ class Account extends CommonObject } + /** + * Returns the fields in order that this bank account should show to the user + * Will return an array with the following values: + * - BankAccountNumber + * - BankCode + * - BankAccountNumberKey + * - DeskCode + * + * Some countries show less or more bank account properties to the user + * + * @return array + * @see useDetailedBBAN + */ + public function getFieldsToShow() + { + //Get the required properties depending on the country + $detailedBBAN = $this->useDetailedBBAN(); + + if ($detailedBBAN == 0) { + return array( + 'BankAccountNumber' + ); + } elseif ($detailedBBAN == 2) { + return array( + 'BankCode', + 'BankAccountNumber' + ); + } + + //Get the order the properties are shown + return self::getAccountNumberOrder(); + } + + /** + * Returns the components of the bank account in order. + * Will return an array with the following values: + * - BankAccountNumber + * - BankCode + * - BankAccountNumberKey + * - DeskCode + * + * @return array + */ + public static function getAccountNumberOrder() + { + global $conf; + + $fieldlists = array( + 'BankCode', + 'DeskCode', + 'BankAccountNumber', + 'BankAccountNumberKey' + ); + + if (!empty($conf->global->BANK_SHOW_ORDER_OPTION)) { + if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) { + if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') { + $fieldlists = array( + 'BankCode', + 'DeskCode', + 'BankAccountNumberKey', + 'BankAccountNumber' + ); + } + } else { + //Replace the old AccountNumber key with the new BankAccountNumber key + $fieldlists = explode( + ' ', + preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', + $conf->global->BANK_SHOW_ORDER_OPTION) + ); + } + } + + return $fieldlists; + } + /** * Initialise an instance with random values. diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a952159b874..026ed206286 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -9,7 +9,7 @@ * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> - * Copyright (C) 2015 Marcos García + * Copyright (C) 2015-2016 Marcos García * * 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 @@ -646,64 +646,42 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default // key = check control key used only when $usedetailedbban = 1 if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+6); - if ($usedetailedbban == 1) - { - $fieldstoshow=array('bank','desk','number','key'); - if ($conf->global->BANK_SHOW_ORDER_OPTION == 1) $fieldstoshow=array('bank','desk','key','number'); - } - else if ($usedetailedbban == 2) - { - $fieldstoshow=array('bank','number'); - } - else dol_print_error('','Value returned by function useDetailedBBAN not managed'); - - foreach ($fieldstoshow as $val) - { - if ($val == 'bank') - { - // Bank code - $tmplength=18; - $pdf->SetXY($curx, $cury+4); - $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0); - $pdf->SetXY($curx, $cury+1); - $curx+=$tmplength; - $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0); - if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+7); - } - if ($val == 'desk') - { - // Desk - $tmplength=18; - $pdf->SetXY($curx, $cury+4); - $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->code_guichet), 0, 'C', 0); - $pdf->SetXY($curx, $cury+1); - $curx+=$tmplength; - $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0); - if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+7); - } - if ($val == 'number') - { - // Number - $tmplength=24; - $pdf->SetXY($curx, $cury+4); - $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->number), 0, 'C', 0); - $pdf->SetXY($curx, $cury+1); - $curx+=$tmplength; - $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0); - if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+7); - } - if ($val == 'key') - { - // Key - $tmplength=13; - $pdf->SetXY($curx, $cury+4); - $pdf->SetFont('','',$default_font_size - 3);$pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($account->cle_rib), 0, 'C', 0); - $pdf->SetXY($curx, $cury+1); - $curx+=$tmplength; - $pdf->SetFont('','B',$default_font_size - 4);$pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); - if (empty($onlynumber)) $pdf->line($curx, $cury+1, $curx, $cury+7); - } - } + + foreach ($account->getFieldsToShow() as $val) + { + $pdf->SetXY($curx, $cury+4); + $pdf->SetFont('','',$default_font_size - 3); + + if ($val == 'BankCode') { + // Bank code + $tmplength = 18; + $content = $account->code_banque; + } elseif ($val == 'DeskCode') { + // Desk + $tmplength = 18; + $content = $account->code_guichet; + } elseif ($val == 'BankAccountNumber') { + // Number + $tmplength = 24; + $content = $account->number; + } elseif ($val == 'BankAccountNumberKey') { + // Key + $tmplength = 13; + $content = $account->cle_rib; + } else { + dol_print_error($this->db, 'Unexpected value for getFieldsToShow: '.$val); + break; + } + + $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0, 'C', 0); + $pdf->SetXY($curx, $cury + 1); + $curx += $tmplength; + $pdf->SetFont('', 'B', $default_font_size - 4); + $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0, 'C', 0); + if (empty($onlynumber)) { + $pdf->line($curx, $cury + 1, $curx, $cury + 7); + } + } $curx=$savcurx; $cury+=8; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index f71b04b7730..fe34f57fd6d 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2010-2013 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Peter Fontaine + * Copyright (C) 2016 Marcos García * * 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 @@ -60,7 +61,7 @@ class CompanyBankAccount extends Account /** * Create bank information record * - * @param Object $user User + * @param User $user User * @return int <0 if KO, >= 0 if OK */ function create($user='') @@ -222,79 +223,27 @@ class CompanyBankAccount extends Account } } - /** - * Return RIB - * - * @param boolean $displayriblabel Prepend or Hide Label - * @return string RIB - */ - function getRibLabel($displayriblabel = true) - { - global $langs,$conf; + /** + * Return RIB + * + * @param boolean $displayriblabel Prepend or Hide Label + * @return string RIB + */ + public function getRibLabel($displayriblabel = true) + { + $rib = ''; - if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) - { - if ($this->label && $displayriblabel) $rib = $this->label." : "; + if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { - // Show fields of bank account - $fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey'; - if (! empty($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber'; - } - else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION; + if ($this->label && $displayriblabel) { + $rib = $this->label." : "; } - $fieldlistsarray=explode(' ',$fieldlists); - foreach($fieldlistsarray as $val) - { - if ($val == 'BankCode') - { - if ($this->useDetailedBBAN() == 1) - { - $rib.=$this->code_banque.' '; - } - } + $rib .= (string) $this; + } - if ($val == 'DeskCode') - { - if ($this->useDetailedBBAN() == 1) - { - $rib.=$this->code_guichet.' '; - } - } - - if ($val == 'BankCode') - { - if ($this->useDetailedBBAN() == 2) - { - $rib.=$this->code_banque.' '; - } - } - - if ($val == 'AccountNumber') - { - $rib.=$this->number.' '; - } - - if ($val == 'BankAccountNumberKey') - { - if ($this->useDetailedBBAN() == 1) - { - $rib.=$this->cle_rib.' '; - } - } - } - } - else - { - $rib=''; - } - - return $rib; - } + return $rib; + } /** * Set RIB as Default diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index c7f087daf72..0d8cdcc1264 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Peter Fontaine - * Copyright (C) 2015 Marcos García + * Copyright (C) 2015-2016 Marcos García * * 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 @@ -254,64 +254,22 @@ if ($socid && $action != 'edit' && $action != "create") print ''.$account->bank.''; // Show fields of bank account - $fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey'; - if (! empty($conf->global->BANK_SHOW_ORDER_OPTION)) + + foreach($account->getFieldsToShow() as $val) { - if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber'; - } - else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION; - } - $fieldlistsarray=explode(' ',$fieldlists); - - foreach($fieldlistsarray as $val) - { - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankCode").''; - print ''.$account->code_banque.''; - print ''; - } - } - if ($val == 'DeskCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("DeskCode").''; - print ''.$account->code_guichet.''; - print ''; - } + if ($val == 'BankCode') { + $content = $account->code_banque; + } elseif ($val == 'DeskCode') { + $content = $account->code_guichet; + } elseif ($val == 'BankAccountNumber') { + $content = $account->number; + } elseif ($val == 'BankAccountNumberKey') { + $content = $account->cle_rib; } - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 2) - { - print ''.$langs->trans("BankCode").''; - print ''.$account->code_banque.''; - print ''; - } - } - - if ($val == 'AccountNumber') - { - print ''.$langs->trans("BankAccountNumber").''; - print ''.$account->number.''; - print ''; - } - - if ($val == 'BankAccountNumberKey') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankAccountNumberKey").''; - print ''.$account->cle_rib.''; - print ''; - } - } + print ''.$langs->trans($val).''; + print ''.$content.''; + print ''; } print ''.$langs->trans("IBAN").''; @@ -473,65 +431,28 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print ''; // Show fields of bank account - $fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey'; - if (! empty($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber'; - } - else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION; - } - $fieldlistsarray=explode(' ',$fieldlists); - - foreach($fieldlistsarray as $val) - { - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankCode").''; - print ''; - print ''; - } + foreach ($account->getFieldsToShow() as $val) { + if ($val == 'BankCode') { + $name = 'code_banque'; + $size = 8; + $content = $account->code_banque; + } elseif ($val == 'DeskCode') { + $name = 'code_guichet'; + $size = 8; + $content = $account->code_guichet; + } elseif ($val == 'BankAccountNumber') { + $name = 'number'; + $size = 18; + $content = $account->number; + } elseif ($val == 'BankAccountNumberKey') { + $name = 'cle_rib'; + $size = 3; + $content = $account->cle_rib; } - if ($val == 'DeskCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("DeskCode").''; - print ''; - print ''; - } - } - - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 2) - { - print ''.$langs->trans("BankCode").''; - print ''; - print ''; - } - } - - if ($val == 'AccountNumber') - { - print ''.$langs->trans("BankAccountNumber").''; - print ''; - print ''; - } - - if ($val == 'BankAccountNumberKey') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankAccountNumberKey").''; - print ''; - print ''; - } - } + print ''.$langs->trans($val).''; + print ''; + print ''; } // IBAN diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index b4f070a2187..951c3a6ef7e 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Peter Fontaine - * Copyright (C) 2015 Marcos García + * Copyright (C) 2015-2016 Marcos García * Copyright (C) 2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -149,64 +149,20 @@ if ($id && $action != 'edit') print ''.$account->bank.''; // Show fields of bank account - $fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey'; - if (! empty($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber'; - } - else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION; - } - $fieldlistsarray=explode(' ',$fieldlists); - - foreach($fieldlistsarray as $val) - { - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankCode").''; - print ''.$account->code_banque.''; - print ''; - } - } - if ($val == 'DeskCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("DeskCode").''; - print ''.$account->code_guichet.''; - print ''; - } + foreach ($account->getFieldsToShow() as $val) { + if ($val == 'BankCode') { + $content = $account->code_banque; + } elseif ($val == 'DeskCode') { + $content = $account->code_guichet; + } elseif ($val == 'BankAccountNumber') { + $content = $account->number; + } elseif ($val == 'BankAccountNumberKey') { + $content = $account->cle_rib; } - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 2) - { - print ''.$langs->trans("BankCode").''; - print ''.$account->code_banque.''; - print ''; - } - } - - if ($val == 'AccountNumber') - { - print ''.$langs->trans("BankAccountNumber").''; - print ''.$account->number.''; - print ''; - } - - if ($val == 'BankAccountNumberKey') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankAccountNumberKey").''; - print ''.$account->cle_rib.''; - print ''; - } - } + print ''.$langs->trans($val).''; + print ''.$content.''; + print ''; } print ''.$langs->trans("IBAN").''; @@ -290,65 +246,28 @@ if ($id && $action == 'edit' && $user->rights->user->user->creer) print ''; // Show fields of bank account - $fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey'; - if (! empty($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber'; - } - else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION; - } - $fieldlistsarray=explode(' ',$fieldlists); - - foreach($fieldlistsarray as $val) - { - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankCode").''; - print ''; - print ''; - } + foreach ($account->getFieldsToShow() as $val) { + if ($val == 'BankCode') { + $name = 'code_banque'; + $size = 8; + $content = $account->code_banque; + } elseif ($val == 'DeskCode') { + $name = 'code_guichet'; + $size = 8; + $content = $account->code_guichet; + } elseif ($val == 'BankAccountNumber') { + $name = 'number'; + $size = 18; + $content = $account->number; + } elseif ($val == 'BankAccountNumberKey') { + $name = 'cle_rib'; + $size = 3; + $content = $account->cle_rib; } - if ($val == 'DeskCode') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("DeskCode").''; - print ''; - print ''; - } - } - - if ($val == 'BankCode') - { - if ($account->useDetailedBBAN() == 2) - { - print ''.$langs->trans("BankCode").''; - print ''; - print ''; - } - } - - if ($val == 'AccountNumber') - { - print ''.$langs->trans("BankAccountNumber").''; - print ''; - print ''; - } - - if ($val == 'BankAccountNumberKey') - { - if ($account->useDetailedBBAN() == 1) - { - print ''.$langs->trans("BankAccountNumberKey").''; - print ''; - print ''; - } - } + print ''.$langs->trans($val).''; + print ''; + print ''; } // IBAN diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index a91d064c7f8..4e88233fe35 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Peter Fontaine * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Marcos García * * 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 @@ -57,7 +58,7 @@ class UserBankAccount extends Account /** * Create bank information record * - * @param Object $user User + * @param User $user User * @return int <0 if KO, >= 0 if OK */ function create($user='') @@ -177,78 +178,26 @@ class UserBankAccount extends Account } } - /** - * Return RIB - * - * @param boolean $displayriblabel Prepend or Hide Label - * @return string RIB - */ - function getRibLabel($displayriblabel = true) - { - global $langs,$conf; + /** + * Return RIB + * + * @param boolean $displayriblabel Prepend or Hide Label + * @return string RIB + */ + public function getRibLabel($displayriblabel = true) + { + $rib = ''; - if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) - { - if ($this->label && $displayriblabel) $rib = $this->label." : "; + if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { - // Show fields of bank account - $fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey'; - if (! empty($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) - { - if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber'; - } - else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION; + if ($this->label && $displayriblabel) { + $rib = $this->label." : "; } - $fieldlistsarray=explode(' ',$fieldlists); - foreach($fieldlistsarray as $val) - { - if ($val == 'BankCode') - { - if ($this->useDetailedBBAN() == 1) - { - $rib.=$this->code_banque.' '; - } - } + $rib .= (string) $this; + } - if ($val == 'DeskCode') - { - if ($this->useDetailedBBAN() == 1) - { - $rib.=$this->code_guichet.' '; - } - } - - if ($val == 'BankCode') - { - if ($this->useDetailedBBAN() == 2) - { - $rib.=$this->code_banque.' '; - } - } - - if ($val == 'AccountNumber') - { - $rib.=$this->number.' '; - } - - if ($val == 'BankAccountNumberKey') - { - if ($this->useDetailedBBAN() == 1) - { - $rib.=$this->cle_rib.' '; - } - } - } - } - else - { - $rib=''; - } - - return $rib; - } + return $rib; + } } From eff5e2ebd7e611fde44f9693cbfe8a722ae93db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 19 Mar 2016 23:02:09 +0100 Subject: [PATCH 02/78] Replaced old AccountNumber key with BankAccountNumber key --- htdocs/admin/bank.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 048e351044d..e15987b69cb 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -155,10 +155,10 @@ print "\n"; $bankorder[0][0]=$langs->trans("BankOrderGlobal"); $bankorder[0][1]=$langs->trans("BankOrderGlobalDesc"); -$bankorder[0][2]='BankCode DeskCode AccountNumber BankAccountNumberKey'; +$bankorder[0][2]='BankCode DeskCode BankAccountNumber BankAccountNumberKey'; $bankorder[1][0]=$langs->trans("BankOrderES"); $bankorder[1][1]=$langs->trans("BankOrderESDesc"); -$bankorder[1][2]='BankCode DeskCode BankAccountNumberKey AccountNumber'; +$bankorder[1][2]='BankCode DeskCode BankAccountNumberKey BankAccountNumber'; $var = true; $i=0; From b8f3264f60b7174674746b3ea9499e64d7c14162 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 29 Mar 2016 11:37:35 +0200 Subject: [PATCH 03/78] FIX: dont retrieve new buying price on margin display --- htdocs/margin/lib/margins.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index 1f904c44f2d..fa33db181ec 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -104,7 +104,7 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta $marge_tx_ret=''; $marque_tx_ret=''; - if ($fk_pa > 0) { + if ($fk_pa > 0 && empty($paht)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $product = new ProductFournisseur($db); if ($product->fetch_product_fournisseur_price($fk_pa)) From 024f55d46182eb5d10035161fb396d687d2d0376 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 29 Mar 2016 12:02:36 +0200 Subject: [PATCH 04/78] FIX: systematic rounding causes prices to be updated without reason --- htdocs/core/tpl/objectline_create.tpl.php | 6 ------ htdocs/core/tpl/objectline_edit.tpl.php | 6 ------ 2 files changed, 12 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 108fb8e1339..feeb61a11e4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -320,18 +320,12 @@ if (! empty($usemargins) && $user->rights->margins->creer) jQuery(document).ready(function() { global->DISPLAY_MARGIN_RATES)) { ?> - $('#addline').click(function (e) { - return checkFreeLine(e, "np_marginRate"); - }); $("input[name='np_marginRate']:first").blur(function(e) { return checkFreeLine(e, "np_marginRate"); }); global->DISPLAY_MARK_RATES)) { ?> - $('#addline').click(function (e) { - return checkFreeLine(e, "np_markRate"); - }); $("input[name='np_markRate']:first").blur(function(e) { return checkFreeLine(e, "np_markRate"); }); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index bb75b007524..a9f86f3123c 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -247,9 +247,6 @@ if (! empty($conf->margin->enabled)) if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?> - $('#savelinebutton').click(function (e) { - return checkEditLine(e, "np_marginRate"); - }); $("input[name='np_marginRate']:first").blur(function(e) { return checkEditLine(e, "np_marginRate"); }); @@ -258,9 +255,6 @@ if (! empty($conf->margin->enabled)) if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?> - $('#savelinebutton').click(function (e) { - return checkEditLine(e, "np_markRate"); - }); $("input[name='np_markRate']:first").blur(function(e) { return checkEditLine(e, "np_markRate"); }); From f3ae67a434db3993980c47dd1f9281df930cac21 Mon Sep 17 00:00:00 2001 From: nka11 Date: Tue, 5 Apr 2016 22:17:52 +0200 Subject: [PATCH 05/78] added customer API --- htdocs/societe/class/api_customer.class.php | 302 ++++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 htdocs/societe/class/api_customer.class.php diff --git a/htdocs/societe/class/api_customer.class.php b/htdocs/societe/class/api_customer.class.php new file mode 100644 index 00000000000..b189ef70e70 --- /dev/null +++ b/htdocs/societe/class/api_customer.class.php @@ -0,0 +1,302 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + use Luracast\Restler\RestException; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; + +/** + * API class for client object + * + * @smart-auto-routing false + * @access protected + * @class DolibarrApiAccess {@requires user,external} + * + */ +class CustomerApi extends DolibarrApi +{ + /** + * + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'name' + ); + + /** + * @var Client $customer {@type Client} + */ + public $customer; + /** + * @var ContactApi $contactapi {@type ContactApi} + */ + public $contactapi; + + /** + * Constructor + * + * @url customer/ + * + */ + function __construct() + { + global $db, $conf; + $this->db = $db; + $this->contactapi = new ContactApi(); + $this->customer = new Client($this->db); + + if (! empty($conf->global->SOCIETE_MAIL_REQUIRED)) { + static::$FIELDS[] = 'email'; + } + } + + /** + * Get properties of a customer object + * + * Return an array with customer informations + * + * @param int $id ID of customer + * @return array|mixed data without useless information + * + * @url GET customer/{id} + * @throws RestException + */ + function get($id) + { + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + + $result = $this->customer->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Customer not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->customer); + } + + /** + * List customers + * + * Get a list of customers + * + * @param Text $email Optional email key + * @param Text $sortfield Sort field + * @param Text $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @return array Array of customer objects + * + * @url GET customer/list + * + */ + function getList($email=NULL , $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + global $db, $conf; + + $obj_ret = array(); + + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + + // If the internal user must only see his customers, force searching by him + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + + $sql = "SELECT s.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; + $sql.= " WHERE s.fk_stcomm = st.id"; + $sql.= " AND s.client IN (1, 3)"; + $sql.= ' AND s.entity IN ('.getEntity('societe', 1).')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; + if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; + if ($socid) $sql.= " AND s.rowid = ".$socid; + if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } + + $sql.= $db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); + $soc_static = new Client($db); + if($soc_static->fetch($obj->rowid)) { + $obj_ret[] = parent::_cleanObjectDatas($soc_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve thirdparties : ' . $sql); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'Thirdparties not found'); + } + return $obj_ret; + } + + /** + * Search customer by email + * + * @param string $email email id + * + * @return object client with given email + * + * @url GET customer/byemail/{email} + */ + function getByEmail($email) { + $res = $this->getList($email); + if (count($res) == 1) { + $customer = $res[0]; + try { + $customer->contacts = $this->contactapi->getList((int)$customer->id); + } catch (Exception $e) {} + return $customer; + } + return $res; + } + + /** + * Create customer object + * + * @param array $request_data Request datas + * @return int ID of customer + * + * @url POST customer/ + */ + function post($request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach($request_data as $field => $value) { + $this->customer->$field = $value; + } + return $this->customer->create(DolibarrApiAccess::$user); + } + + /** + * Update customer + * + * @param int $id Id of thirdparty to update + * @param array $request_data Datas + * @return int + * + * @url PUT customer/{id} + function put($id, $request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + + $result = $this->customer->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Customer not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach($request_data as $field => $value) { + $this->customer->$field = $value; + } + + if($this->customer->update($id, DolibarrApiAccess::$user,1,'','','update')) + return $this->get ($id); + + return false; + } + */ + + /** + * Delete customer + * + * @param int $id Thirparty ID + * @return type + * + * @url DELETE customer/{id} + */ + function delete($id) + { + if(! DolibarrApiAccess::$user->rights->societe->supprimer) { + throw new RestException(401); + } + $result = $this->customer->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Customer not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->customer->delete($id); + } + + /** + * Validate fields before create or update object + * + * @param array $data Datas to validate + * @return array + * + * @throws RestException + */ + function _validate($data) + { + $customer = array(); + foreach (ThirdpartyApi::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $customer[$field] = $data[$field]; + } + return $customer; + } +} From 0978ebc73117ac7cccc0340785330af61122b119 Mon Sep 17 00:00:00 2001 From: nka11 Date: Tue, 5 Apr 2016 15:26:21 +0200 Subject: [PATCH 06/78] Improve categories API to retreive categories of a given Item --- .../categories/class/api_category.class.php | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/htdocs/categories/class/api_category.class.php b/htdocs/categories/class/api_category.class.php index 364147d097d..d66875185a4 100644 --- a/htdocs/categories/class/api_category.class.php +++ b/htdocs/categories/class/api_category.class.php @@ -162,6 +162,86 @@ class CategoryApi extends DolibarrApi } return $obj_ret; } + /** + * List categories of an entity + * + * Get a list of categories + * + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param int $item Id of the item to get categories for + * @return array Array of category objects + * + * @url GET /product/{item}/categories + */ + function getListForItem($type='product', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $item = 0) { + global $db, $conf; + + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } + //if ($type == "") { + //$type="product"; + //} + $sub_type = $type; + $subcol_name = "fk_".$type; + if ($type=="customer" || $type=="supplier") { + $sub_type="societe"; + $subcol_name="fk_soc"; + } + $sql = "SELECT s.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie as s"; + $sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; + $sql.= ' WHERE s.entity IN ('.getEntity('categorie', 1).')'; + $sql.= ' AND s.type='.array_search($type,CategoryApi::$TYPES); + $sql.= ' AND s.rowid = sub.fk_categorie'; + $sql.= ' AND sub.'.$subcol_name.' = '.$item; + + $nbtotalofrecords = 0; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); + $category_static = new Categorie($db); + if($category_static->fetch($obj->rowid)) { + $obj_ret[] = parent::_cleanObjectDatas($category_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve category list : '.$category_static->error); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No category found'); + } + return $obj_ret; + } /** * Get member categories list @@ -193,6 +273,21 @@ class CategoryApi extends DolibarrApi function getListCategoryCustomer($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { return $this->getList('customer', $sortfield, $sortorder, $limit, $page); } + /** + * Get categories for a customer + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * + * @return mixed + * + * @url GET /customer/{cusid}/categories + */ + function getListCustomerCategories($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $cusid) { + return $this->getListForItem('customer', $sortfield, $sortorder, $limit, $page, $cusid); + } /** * Get supplier categories list From 1f723cb8d0b15e922e36532cedf164ed5b6a655d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 7 Apr 2016 14:16:10 +0200 Subject: [PATCH 07/78] FIX : Template email must take care of positino column --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index a815875dc52..97a7434fd02 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -859,13 +859,13 @@ class FormMail extends Form { $ret=array(); - $sql = "SELECT rowid, label, topic, content, lang"; + $sql = "SELECT rowid, label, topic, content, lang, position"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; $sql.= " AND entity IN (".getEntity("c_email_templates").")"; $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; - $sql.= $this->db->order("lang,label","ASC"); + $sql.= $this->db->order("position,lang,label","ASC"); //print $sql; $resql = $this->db->query($sql); From d052eac6fc218ac4af9347a86faea14098549425 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 7 Apr 2016 14:57:41 +0200 Subject: [PATCH 08/78] NEW: add product type filter on turnover report --- htdocs/compta/stats/cabyprodserv.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index e995b06aa6b..7e5a194c0e7 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -55,6 +55,9 @@ $subcat = false; if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; } +// product/service +$selected_type = GETPOST('search_type', 'int'); +if ($selected_type =='') $selected_type = -1; // Date range $year=GETPOST("year"); @@ -124,6 +127,7 @@ $headerparams['q'] = $q; $tableparams = array(); $tableparams['search_categ'] = $selected_cat; +$tableparams['search_type'] = $selected_type; $tableparams['subcat'] = ($subcat === true)?'yes':''; // Adding common parameters @@ -180,7 +184,7 @@ $catotal=0; if ($modecompta == 'CREANCES-DETTES') { - $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label,"; + $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,"; $sql.= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,"; $sql.= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l, ".MAIN_DB_PREFIX."product as p"; @@ -203,6 +207,10 @@ if ($modecompta == 'CREANCES-DETTES') if ($date_start && $date_end) { $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } + if ($selected_type >=0) + { + $sql.= " AND l.product_type = ".$selected_type; + } if ($selected_cat === -2) // Without any category { $sql.=" AND cp.fk_product is null"; @@ -228,6 +236,7 @@ if ($modecompta == 'CREANCES-DETTES') $amount[$obj->rowid] = $obj->amount_ttc; $qty[$obj->rowid] = $obj->qty; $name[$obj->rowid] = $obj->ref . ' - ' . $obj->label; + $type[$obj->rowid] = $obj->product_type; $catotal_ht+=$obj->amount; $catotal+=$obj->amount_ttc; $qtytotal+=$obj->qty; @@ -257,8 +266,14 @@ if ($modecompta == 'CREANCES-DETTES') if ($subcat) { print ' checked'; } - print '>'; - print ''; + print '>'; + // type filter (produit/service) + print ' '; + print $langs->trans("Type"). ': '; + $form->select_type_of_lines(isset($selected_type)?$selected_type:-1,'search_type',1,1,1); + print ''; + + print ''; print ''; print ''; @@ -337,7 +352,7 @@ if ($modecompta == 'CREANCES-DETTES') // Product $fullname=$name[$key]; if ($key >= 0) { - $linkname=''.img_object($langs->trans("ShowProduct"),'product').' '.$fullname.''; + $linkname=''.img_object($langs->trans("ShowProduct"),$type[$key]==0?'product':'service').' '.$fullname.''; } else { $linkname=$langs->trans("PaymentsNotLinkedToProduct"); } From 9d6efde9357d5025745206730651797fb4615862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 7 Apr 2016 17:12:06 +0200 Subject: [PATCH 09/78] Prevent sentry logging error with 3.9 update Since we don't ship the required libraries anymore, if the module had been enabled before upgrade, the code was failing making Dolibarr totally unusable. Mitigated the issue by disabling sentry logging if the required libraries are unavailable. --- htdocs/core/modules/syslog/mod_syslog_sentry.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/modules/syslog/mod_syslog_sentry.php b/htdocs/core/modules/syslog/mod_syslog_sentry.php index afea1a36375..a159a5edf2f 100644 --- a/htdocs/core/modules/syslog/mod_syslog_sentry.php +++ b/htdocs/core/modules/syslog/mod_syslog_sentry.php @@ -145,6 +145,10 @@ class mod_syslog_sentry extends LogHandler implements LogHandlerInterface */ public function export($content) { + if (! $this->isActive()) { + return; + } + global $conf; $dsn = $conf->global->SYSLOG_SENTRY_DSN; $client = new Raven_Client( From eb7bba956805d9b3e582e96fc688c056a1472050 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 15:41:01 +0200 Subject: [PATCH 10/78] Fix translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e621d98641c..069ced7854e 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1494,7 +1494,7 @@ FCKeditorForProduct=WYSIWIG creation/edition of products/services description an FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formating when building PDF files. FCKeditorForMailing= WYSIWIG creation/edition for mass eMailings (Tools->eMailing) FCKeditorForUserSignature=WYSIWIG creation/edition of user signature -FCKeditorForMail=WYSIWIG creation/edition for all mail (except Outils->eMailing) +FCKeditorForMail=WYSIWIG creation/edition for all mail (except Tools->eMailing) ##### OSCommerce 1 ##### OSCommerceErrorConnectOkButWrongDatabase=Connection succeeded but database doesn't look to be an OSCommerce database (Key %s not found in table %s). OSCommerceTestOk=Connection to server '%s' on database '%s' with user '%s' successfull. From 5753f217451b33a589feab210322e81f81cc9f56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 11:42:02 +0200 Subject: [PATCH 11/78] Missing translations --- htdocs/langs/en_US/agenda.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index cb7959a0901..d8747b74fe6 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -62,6 +62,9 @@ SupplierInvoiceSentByEMail=Supplier invoice %s sent by EMail ShippingSentByEMail=Shipment %s sent by EMail ShippingValidated= Shipment %s validated InterventionSentByEMail=Intervention %s sent by EMail +ProposalDeleted=Proposal deleted +OrderDeleted=Order deleted +InvoiceDeleted=Invoice deleted NewCompanyToDolibarr= Third party created DateActionPlannedStart= Planned start date DateActionPlannedEnd= Planned end date From 80caf58866d5de31f39d99d46d3b3155cea65134 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 19:16:40 +0200 Subject: [PATCH 12/78] FIX Default vat is not set correctly when an error occured and we use VAT identified by a code. --- htdocs/core/class/html.form.class.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c925a587b33..9a4fb17fa9c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4013,11 +4013,18 @@ class Form $return=''; - // Define defaultnpr and defaultttx + // Define defaultnpr, defaultttx and defaultcode $defaultnpr=($info_bits & 0x01); $defaultnpr=(preg_match('/\*/',$selectedrate) ? 1 : $defaultnpr); $defaulttx=str_replace('*','',$selectedrate); - + $defaultcode=''; + if (preg_match('/\s*\((.*)\)/', $defaulttx, $reg)) + { + $defaultcode=$reg[1]; + $defaulttx=preg_replace('/\s*\(.*\)/','',$defaulttx); + } + //var_dump($defaulttx.'-'.$defaultnpr.'-'.$defaultcode); + // Check parameters if (is_object($societe_vendeuse) && ! $societe_vendeuse->country_code) { @@ -4113,9 +4120,13 @@ class Form $return.= $rate['nprtva'] ? '*': ''; if ($addcode && $rate['code']) $return.=' ('.$rate['code'].')'; $return.= '"'; - if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) + if ($defaultcode) { - $return.= ' selected'; + if ($defaultcode == $rate['code']) $return.= ' selected'; + } + elseif ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) + { + $return.= ' selected'; } $return.= '>'.vatrate($rate['libtva']); //$return.=($rate['code']?' '.$rate['code']:''); From daa1aed3633ead45c650d16bfade6ca30075f21c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 19:31:18 +0200 Subject: [PATCH 13/78] Bad placeholder --- htdocs/societe/soc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 52f30317a3e..cb4f65abeed 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1885,7 +1885,7 @@ else 'name' => 'soc_origin', 'label' => $langs->trans('MergeOriginThirdparty'), 'type' => 'other', - 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 1, 0, 0, array(), 0, 'minwidth200') + 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') ) ); From f90cffd74ab07245968688514f0e7fd63040a71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 9 Apr 2016 15:42:53 +0200 Subject: [PATCH 14/78] Update nusoap.php re-establish user-agent --- htdocs/includes/nusoap/lib/nusoap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/nusoap/lib/nusoap.php b/htdocs/includes/nusoap/lib/nusoap.php index 403d74b13e9..6defe0e6004 100644 --- a/htdocs/includes/nusoap/lib/nusoap.php +++ b/htdocs/includes/nusoap/lib/nusoap.php @@ -2217,7 +2217,7 @@ class soap_transport_http extends nusoap_base { } $this->use_curl = $use_curl; preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); - if (isset($rev[1])) $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')'); + $this->setHeader('User-Agent', $this->title.'/'.$this->version.(isset($rev[1])?' ('.$rev[1].')':'')); } /** From 5967330004cac08293dbf64ba71c3e5d1fe2e419 Mon Sep 17 00:00:00 2001 From: nka11 Date: Sat, 9 Apr 2016 21:39:12 +0200 Subject: [PATCH 15/78] merge api_customer to api_ thirdparty --- htdocs/societe/class/api_customer.class.php | 302 ------------------ htdocs/societe/class/api_thirdparty.class.php | 190 ++++++++--- 2 files changed, 144 insertions(+), 348 deletions(-) delete mode 100644 htdocs/societe/class/api_customer.class.php diff --git a/htdocs/societe/class/api_customer.class.php b/htdocs/societe/class/api_customer.class.php deleted file mode 100644 index b189ef70e70..00000000000 --- a/htdocs/societe/class/api_customer.class.php +++ /dev/null @@ -1,302 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - use Luracast\Restler\RestException; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; - -/** - * API class for client object - * - * @smart-auto-routing false - * @access protected - * @class DolibarrApiAccess {@requires user,external} - * - */ -class CustomerApi extends DolibarrApi -{ - /** - * - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'name' - ); - - /** - * @var Client $customer {@type Client} - */ - public $customer; - /** - * @var ContactApi $contactapi {@type ContactApi} - */ - public $contactapi; - - /** - * Constructor - * - * @url customer/ - * - */ - function __construct() - { - global $db, $conf; - $this->db = $db; - $this->contactapi = new ContactApi(); - $this->customer = new Client($this->db); - - if (! empty($conf->global->SOCIETE_MAIL_REQUIRED)) { - static::$FIELDS[] = 'email'; - } - } - - /** - * Get properties of a customer object - * - * Return an array with customer informations - * - * @param int $id ID of customer - * @return array|mixed data without useless information - * - * @url GET customer/{id} - * @throws RestException - */ - function get($id) - { - if(! DolibarrApiAccess::$user->rights->societe->lire) { - throw new RestException(401); - } - - $result = $this->customer->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Customer not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - return $this->_cleanObjectDatas($this->customer); - } - - /** - * List customers - * - * Get a list of customers - * - * @param Text $email Optional email key - * @param Text $sortfield Sort field - * @param Text $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @return array Array of customer objects - * - * @url GET customer/list - * - */ - function getList($email=NULL , $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - global $db, $conf; - - $obj_ret = array(); - - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; - - // If the internal user must only see his customers, force searching by him - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - - $sql = "SELECT s.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; - $sql.= " WHERE s.fk_stcomm = st.id"; - $sql.= " AND s.client IN (1, 3)"; - $sql.= ' AND s.entity IN ('.getEntity('societe', 1).')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; - if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; - if ($socid) $sql.= " AND s.rowid = ".$socid; - if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - - $nbtotalofrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - } - - $sql.= $db->order($sortfield, $sortorder); - - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; - - $sql.= $db->plimit($limit + 1, $offset); - } - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - while ($i < $num) - { - $obj = $db->fetch_object($result); - $soc_static = new Client($db); - if($soc_static->fetch($obj->rowid)) { - $obj_ret[] = parent::_cleanObjectDatas($soc_static); - } - $i++; - } - } - else { - throw new RestException(503, 'Error when retrieve thirdparties : ' . $sql); - } - if( ! count($obj_ret)) { - throw new RestException(404, 'Thirdparties not found'); - } - return $obj_ret; - } - - /** - * Search customer by email - * - * @param string $email email id - * - * @return object client with given email - * - * @url GET customer/byemail/{email} - */ - function getByEmail($email) { - $res = $this->getList($email); - if (count($res) == 1) { - $customer = $res[0]; - try { - $customer->contacts = $this->contactapi->getList((int)$customer->id); - } catch (Exception $e) {} - return $customer; - } - return $res; - } - - /** - * Create customer object - * - * @param array $request_data Request datas - * @return int ID of customer - * - * @url POST customer/ - */ - function post($request_data = NULL) - { - if(! DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); - - foreach($request_data as $field => $value) { - $this->customer->$field = $value; - } - return $this->customer->create(DolibarrApiAccess::$user); - } - - /** - * Update customer - * - * @param int $id Id of thirdparty to update - * @param array $request_data Datas - * @return int - * - * @url PUT customer/{id} - function put($id, $request_data = NULL) - { - if(! DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - - $result = $this->customer->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Customer not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - foreach($request_data as $field => $value) { - $this->customer->$field = $value; - } - - if($this->customer->update($id, DolibarrApiAccess::$user,1,'','','update')) - return $this->get ($id); - - return false; - } - */ - - /** - * Delete customer - * - * @param int $id Thirparty ID - * @return type - * - * @url DELETE customer/{id} - */ - function delete($id) - { - if(! DolibarrApiAccess::$user->rights->societe->supprimer) { - throw new RestException(401); - } - $result = $this->customer->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Customer not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - return $this->customer->delete($id); - } - - /** - * Validate fields before create or update object - * - * @param array $data Datas to validate - * @return array - * - * @throws RestException - */ - function _validate($data) - { - $customer = array(); - foreach (ThirdpartyApi::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $customer[$field] = $data[$field]; - } - return $customer; - } -} diff --git a/htdocs/societe/class/api_thirdparty.class.php b/htdocs/societe/class/api_thirdparty.class.php index a30e148b3d2..604d1f61f63 100644 --- a/htdocs/societe/class/api_thirdparty.class.php +++ b/htdocs/societe/class/api_thirdparty.class.php @@ -40,6 +40,10 @@ class ThirdpartyApi extends DolibarrApi * @var Societe $company {@type Societe} */ public $company; + /** + * @var Customer $customer {@type Client} + */ + public $customer; /** * Constructor @@ -52,39 +56,87 @@ class ThirdpartyApi extends DolibarrApi global $db, $conf; $this->db = $db; $this->company = new Societe($this->db); + $this->customer = new Client($this->db); if (! empty($conf->global->SOCIETE_MAIL_REQUIRED)) { static::$FIELDS[] = 'email'; } } - /** - * Get properties of a thirdparty object - * - * Return an array with thirdparty informations - * - * @param int $id ID of thirdparty - * @return array|mixed data without useless information + /** + * Get properties of a customer object + * + * Return an array with customer informations + * + * @param int $id ID of customer + * @return array|mixed data without useless information * - * @url GET thirdparty/{id} - * @throws RestException + * @url GET customer/{id} + * @throws RestException + */ + function getCustomer($id) + { + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + + $result = $this->customer->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Customer not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->customer); + } + + /** + * Search customer by email + * + * @param string $email email id + * + * @return object client with given email + * + * @url GET customer/byemail/{email} */ + function getByEmail($email) { + $res = $this->getList(1,$email); + if (count($res) == 1) { + $customer = $res[0]; + return $customer; + } + return $res; + } + + /** + * Get properties of a thirdparty object + * + * Return an array with thirdparty informations + * + * @param int $id ID of thirdparty + * @return array|mixed data without useless information + * + * @url GET thirdparty/{id} + * @throws RestException + */ function get($id) { - if(! DolibarrApiAccess::$user->rights->societe->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } - $result = $this->company->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Thirdparty not found'); - } + $result = $this->company->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->company); + return $this->_cleanObjectDatas($this->company); } /** @@ -104,7 +156,7 @@ class ThirdpartyApi extends DolibarrApi * @url GET /thirdparty/list * */ - function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function getList($mode=0, $email=NULL, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { global $db, $conf; $obj_ret = array(); @@ -126,6 +178,7 @@ class ThirdpartyApi extends DolibarrApi if ($mode == 3) $sql.= " AND s.client IN (0)"; $sql.= ' AND s.entity IN ('.getEntity('societe', 1).')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; + if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale @@ -183,6 +236,7 @@ class ThirdpartyApi extends DolibarrApi * @return array List of customers * * @url GET /thirdparty/list/customers + * @url GET /customer/list */ function getListCustomers() { return $this->getList(1); @@ -196,7 +250,7 @@ class ThirdpartyApi extends DolibarrApi * @url GET /thirdparty/list/prospects */ function getListProspects() { - return $this->getList('',1); + return $this->getList(2); } /** @@ -207,7 +261,7 @@ class ThirdpartyApi extends DolibarrApi * @url GET /thirdparty/list/others */ function getListOthers() { - return $this->getList('','',1); + return $this->getList(3); } /** @@ -220,16 +274,31 @@ class ThirdpartyApi extends DolibarrApi */ function post($request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); - - foreach($request_data as $field => $value) { - $this->company->$field = $value; - } - return $this->company->create(DolibarrApiAccess::$user); + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach($request_data as $field => $value) { + $this->company->$field = $value; + } + return $this->company->create(DolibarrApiAccess::$user); + } + + + /** + * Create customer object + * + * @param array $request_data Request datas + * @return int ID of thirdparty + * + * @url POST customer/ + */ + function postCustomer($request_data) { + $this->post($request_data); + $this->company->set_as_client(); + return $this->company->id; } /** @@ -265,6 +334,36 @@ class ThirdpartyApi extends DolibarrApi return false; } + /** + * Update customer + * + * @param int $id Id of thirdparty to update + * @param array $request_data Datas + * @return int + * + * @url PUT customer/{id} + */ + function putClient($id, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $result = $this->customer->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Customer not found'); + } + if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach($request_data as $field => $value) { + $this->customer->$field = $value; + } + + if($this->customer->update($id, DolibarrApiAccess::$user,1,'','','update')) + return $this->get ($id); + + return false; + } /** * Delete thirdparty @@ -273,22 +372,21 @@ class ThirdpartyApi extends DolibarrApi * @return type * * @url DELETE thirdparty/{id} + * @url DELETE customer/{id} */ function delete($id) { - if(! DolibarrApiAccess::$user->rights->societe->supprimer) { - throw new RestException(401); - } - $result = $this->company->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Thirdparty not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - return $this->company->delete($id); + if(! DolibarrApiAccess::$user->rights->societe->supprimer) { + throw new RestException(401); + } + $result = $this->company->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + return $this->company->delete($id); } /** From 9169adf4ceab98ad04a180653f205b4b928b7cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:34:55 +0200 Subject: [PATCH 16/78] FIX #4766 VAT not shown in supplier invoice popup Close #4766 --- htdocs/compta/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 5fb1d638a88..5c93c1e62db 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Marcos García * * 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 @@ -230,7 +231,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) */ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { - $sql = "SELECT f.ref, f.rowid, f.total_ht, f.tva as total_tva, f.total_ttc, f.type"; + $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type"; $sql.= ", s.nom as name"; $sql.= ", s.rowid as socid"; $sql.= ", s.code_fournisseur"; From b2f922291fefb66eb845ae7fce78ef536bcf60ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:38:58 +0200 Subject: [PATCH 17/78] FIX #4851 Project selector in supplier invoices shows the project label twice Close #4851 --- htdocs/core/class/html.formprojet.class.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 2b7f76dedf9..4c094061ee4 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -180,7 +180,7 @@ class FormProjets continue; } - $labeltoshow=dol_trunc($obj->ref,18).' - '.$obj->title; + $labeltoshow=dol_trunc($obj->ref,18); //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')'; $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 890772326ea..42418184c4f 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1474,7 +1474,7 @@ class FactureFournisseur extends CommonInvoice if (! empty($this->total_ht)) $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_tva)) - $label.= '
' . $langs->trans('TVA') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + $label.= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_ttc)) $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); From 1026484da1ec129a47cc84d4ec16e3d4863189df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:48:42 +0200 Subject: [PATCH 18/78] FIX #4748 Supplier invoice payment confirmation amount is not translated Close #4748 --- htdocs/fourn/facture/paiement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 81fe1d6b345..d69c2df9a94 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -432,7 +432,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $preselectedchoice=$addwarning?'no':'yes'; print '
'; - $text=$langs->trans('ConfirmSupplierPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); + $text=$langs->trans('ConfirmSupplierPayment', price($totalpayment),$langs->trans("Currency".$conf->currency)); if (GETPOST('closepaidinvoices')) { $text.='
'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); From 7cc1288bb2c4c9b86802f761664ff5903ff1b8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:54:13 +0200 Subject: [PATCH 19/78] FIX #4743 UI glitch in project summary page Close #4743 --- htdocs/projet/element.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 1be43fe94dd..c475dcbcae0 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -344,8 +344,7 @@ $langs->load("orders"); $langs->load("proposals"); $langs->load("margins"); -//print load_fiche_titre($langs->trans("Profit"),'','title_accountancy'); -print '
'.img_picto("", "title_accountancy").' '.$langs->trans("Profit").'

'; +print load_fiche_titre($langs->trans("Profit"), '', 'title_accountancy'); print ''; print ''; From 3135cf720d8ccfc8ff09b821e664fd4be3a66edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:56:45 +0200 Subject: [PATCH 20/78] FIX #4737 Bank transacion type selector translation is cropped Close #4737 --- htdocs/compta/bank/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index 80befe3d433..d4f4b82a96b 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -210,7 +210,7 @@ if ($resql) print ''; print ''; print ''; print ''; print ''; print "\n"; From af473df2143a275a4d1704a2ac2dfaaefa5dfa48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 23:27:42 +0200 Subject: [PATCH 23/78] FIX #4742 Able to delete a supplier invoice with a registered payment Close #4742 --- htdocs/fourn/facture/card.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c2b2c587736..7887e8cc6ed 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2270,7 +2270,11 @@ else // Delete if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer) { - print ''.$langs->trans('Delete').''; + if ($object->getSommePaiement()) { + print ''; + } else { + print ''.$langs->trans('Delete').''; + } } print ''; print '
'; From 15d927375132469cd89c7fcf834be5ccc9886495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 10 Apr 2016 00:30:31 +0200 Subject: [PATCH 24/78] FIX #4747 Missing UI background when registering a supplier invoice payment Close #4747 --- htdocs/fourn/facture/paiement.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 758885cef58..dcaabd160f8 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -281,9 +281,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; + dol_fiche_head(); + print '
  '; - $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1, 8); + $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1); print ''; From b9de3d5852d59d0ca9ca0f73852ffdb431e29fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 23:03:00 +0200 Subject: [PATCH 21/78] FIX #4442 Missing translation in Banks menu Close #4442 --- htdocs/core/menus/standard/eldy.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 8d6882c26c2..b6a98b1c2d3 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -970,6 +970,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("withdrawals"); $langs->load("banks"); $langs->load("bills"); + $langs->load('categories'); // Bank-Caisse if (! empty($conf->banque->enabled)) From 865f9defff1b2ca8b23684c59e44f03b94bd0d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 23:08:47 +0200 Subject: [PATCH 22/78] FIX #4424 Missing email of user popup in supplier orders area Close #4424 --- htdocs/fourn/commande/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index c877589851d..510ca2755be 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -245,7 +245,7 @@ if (! empty($conf->fournisseur->enabled)) /* * List of users allowed */ -$sql = "SELECT u.rowid, u.lastname, u.firstname"; +$sql = "SELECT u.rowid, u.lastname, u.firstname, u.email"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u,"; $sql.= " ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as rd"; @@ -278,6 +278,7 @@ if ($resql) $userstatic->id=$obj->rowid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->email=$obj->email; print $userstatic->getNomUrl(1); print '
'; - print ''; print '
'.$langs->trans('Payment').'
'.$langs->trans('Company').''; $supplierstatic->id=$obj->socid; $supplierstatic->name=$obj->name; @@ -311,6 +312,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print '
'; + dol_fiche_end(); $parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -337,7 +339,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { $i = 0; print '
'; - print $langs->trans('Invoices').'
'; if(!empty($conf->global->FAC_AUTO_FILLJS)){ //Add js for AutoFill From 7acbf1dd92112dfbdfdc6228ac4e8f0660531a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 10 Apr 2016 01:00:27 +0200 Subject: [PATCH 25/78] FIX #4874 SQL error when listing users Close #4874 --- htdocs/user/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 8710dc87e04..3d787762a8c 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Marcos García * * 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 @@ -201,7 +202,9 @@ if ($search_login != '') $sql.= natural_search("u.login", $search_login); if ($search_lastname != '') $sql.= natural_search("u.lastname", $search_lastname); if ($search_firstname != '') $sql.= natural_search("u.firstname", $search_firstname); if ($search_gender != '' && $search_gender != '-1') $sql.= " AND u.gender = '".$search_gender."'"; -if ($search_employee >= 0) $sql.= natural_search("u.employee", $search_employee); +if (is_numeric($search_employee) && $search_employee >= 0) { + $sql .= ' AND u.employee = '.(int) $search_employee; +} if ($search_accountancy_code != '') $sql.= natural_search("u.accountancy_code", $search_accountancy_code); if ($search_email != '') $sql.= natural_search("u.email", $search_email); if ($search_statut != '' && $search_statut >= 0) $sql.= " AND (u.statut=".$search_statut.")"; From d0356d6bd035c629a9e2fcfa2b88b6ec60b31184 Mon Sep 17 00:00:00 2001 From: nka11 Date: Sun, 10 Apr 2016 13:57:53 +0200 Subject: [PATCH 26/78] new api class for accounts, filtering on order api --- htdocs/commande/class/api_commande.class.php | 22 +- htdocs/societe/class/api_contact.class.php | 3 +- htdocs/user/class/api_account.class.php | 212 +++++++++++++++++++ 3 files changed, 233 insertions(+), 4 deletions(-) create mode 100644 htdocs/user/class/api_account.class.php diff --git a/htdocs/commande/class/api_commande.class.php b/htdocs/commande/class/api_commande.class.php index e8266fe6383..f0f346ecdb2 100644 --- a/htdocs/commande/class/api_commande.class.php +++ b/htdocs/commande/class/api_commande.class.php @@ -106,12 +106,12 @@ class CommandeApi extends DolibarrApi * @url GET /order/list * @return array Array of order objects */ - function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function getList($mode=0, $societe = "", $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { global $db, $conf; $obj_ret = array(); - - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + // case of external user, $societe param is ignored and replaced by user's socid + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; // If the internal user must only see his customers, force searching by him if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; @@ -178,6 +178,22 @@ class CommandeApi extends DolibarrApi } return $obj_ret; } + + /** + * List orders for specific thirdparty + * + * Get a list of orders + * + * @param int $socid Id of customer + * + * @url GET /customer/{socid}/order/list + * @url GET /thirdparty/{socid}/order/list + * @return array Array of order objects + */ + function getListForSoc($socid = "") { + return getList(0,$socid); + } + /** * Create order object diff --git a/htdocs/societe/class/api_contact.class.php b/htdocs/societe/class/api_contact.class.php index 09f92dd1364..1021913f16e 100644 --- a/htdocs/societe/class/api_contact.class.php +++ b/htdocs/societe/class/api_contact.class.php @@ -17,7 +17,7 @@ use Luracast\Restler\RestException; -require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; /** * API class for contact object @@ -100,6 +100,7 @@ class ContactApi extends DolibarrApi * @url GET /contact/list * @url GET /contact/list/{socid} * @url GET /thirdparty/{socid}/contacts + * @url GET /customer/{socid}/contacts * * @throws RestException */ diff --git a/htdocs/user/class/api_account.class.php b/htdocs/user/class/api_account.class.php new file mode 100644 index 00000000000..956584d9292 --- /dev/null +++ b/htdocs/user/class/api_account.class.php @@ -0,0 +1,212 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +use Luracast\Restler\RestException; + +//require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + +/** + * API class for user object + * + * @smart-auto-routing false + * @access protected + * @class DolibarrApiAccess {@requires user,external} + * + */ +class AccountApi extends DolibarrApi +{ + /** + * + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'login' + ); + + /** + * @var User $account {@type User} + */ + public $account; + + /** + * Constructor + * + * @url account/ + * + */ + function __construct() { + global $db, $conf; + $this->db = $db; + $this->account = new User($this->db); + } + + /** + * Get properties of an account object + * + * Return an array with account informations + * + * @param int $id ID of account + * @return array|mixed data without useless information + * + * @url GET account/{user} + * @throws RestException + */ + function get($id) { + //if (!DolibarrApiAccess::$user->rights->user->lire) + //{ + //throw new RestException(401); + //} + + $result = $this->account->fetch($id); + if (!$result) + { + throw new RestException(404, 'User not found'); + } + + if (!DolibarrApi::_checkAccessToResource('user', $this->account->id, 'user')) + { + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->account); + } + + /** + * Create account object from contact + * + * @param int $contactid Id of contact + * @param array $request_data Request datas + * @return int ID of account + * + * @url POST /contact/{contactid}/createAccount + */ + function createFromContact($contactid, $request_data = NULL) { + //if (!DolibarrApiAccess::$user->rights->user->creer) + //{ + //throw new RestException(401); + //} + // + if (!isset($request_data["login"])) + throw new RestException(400, "login field missing"); + if (!isset($request_data["password"])) + throw new RestException(400, "password field missing"); + if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { + throw new RestException(401); + } + $contact = new Contact($this->db); + $contact->fetch($contactid); + if ($contact->id <= 0) { + throw new RestException(404, 'Contact not found'); + } + + if (!DolibarrApi::_checkAccessToResource('contact', $contact->id, 'socpeople&societe')) { + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + } + // Check mandatory fields + $login = $request_data["login"]; + $password = $request_data["password"]; + $result = $this->account->create_from_contact($contact,$login,$password); + if ($result <= 0) { + throw new RestException(500, "User not created"); + } + // password parameter not used in create_from_contact + $this->account->setPassword($this->account,$password); + return $result; + } + + /** + * Update account + * + * @param int $id Id of account to update + * @param array $request_data Datas + * @return int + * + * @url PUT account/{id} + */ + function put($id, $request_data = NULL) { + //if (!DolibarrApiAccess::$user->rights->user->creer) + //{// + //throw new RestException(401); + //} + + $result = $this->account->fetch($id); + if (!$result) + { + throw new RestException(404, 'Account not found'); + } + + if (!DolibarrApi::_checkAccessToResource('user', $this->account->id, 'user')) + { + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + } + + foreach ($request_data as $field => $value) + { + $this->account->$field = $value; + } + + if ($this->account->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) + return $this->get($id); + + return false; + } + + /** + * Delete account + * + * @param int $id Account ID + * @return array + * + * @url DELETE account/{id} + */ + function delete($id) { + //if (!DolibarrApiAccess::$user->rights->user->supprimer) + //{ + //throw new RestException(401); + //} + $result = $this->account->fetch($id); + if (!$result) + { + throw new RestException(404, 'User not found'); + } + + if (!DolibarrApi::_checkAccessToResource('user', $this->account->id, 'user')) + { + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + } + + return $this->account->delete($id); + } + + /** + * Validate fields before create or update object + * + * @param array $data Data to validate + * @return array + * @throws RestException + */ + function _validate($data) { + $account = array(); + foreach (UserApi::$FIELDS as $field) + { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $account[$field] = $data[$field]; + } + return $account; + } +} From cea87dccbb81cea1501672141232ad5a410e58c1 Mon Sep 17 00:00:00 2001 From: nka11 Date: Sun, 10 Apr 2016 13:59:52 +0200 Subject: [PATCH 27/78] crlf fix --- htdocs/includes/pdfmake/pdfmake.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/includes/pdfmake/pdfmake.js b/htdocs/includes/pdfmake/pdfmake.js index 5f2ffb1591e..6e458e51cb0 100644 --- a/htdocs/includes/pdfmake/pdfmake.js +++ b/htdocs/includes/pdfmake/pdfmake.js @@ -14757,16 +14757,16 @@ /* 8 */ /***/ function(module, exports) { - module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - module.children = []; - module.webpackPolyfill = 1; - } - return module; - } + module.exports = function(module) { + if(!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + module.children = []; + module.webpackPolyfill = 1; + } + return module; + } /***/ }, @@ -68134,14 +68134,14 @@ /* 106 */ /***/ function(module, exports) { - module.exports = function() { throw new Error("define cannot be used indirect"); }; + module.exports = function() { throw new Error("define cannot be used indirect"); }; /***/ }, /* 107 */ /***/ function(module, exports) { - /* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {module.exports = __webpack_amd_options__; + /* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {module.exports = __webpack_amd_options__; /* WEBPACK VAR INJECTION */}.call(exports, {})) From 132cdd9ed414c67752229b9d8744c9a3be0a4899 Mon Sep 17 00:00:00 2001 From: nka11 Date: Sun, 10 Apr 2016 14:15:38 +0200 Subject: [PATCH 28/78] Fix coding style errors --- .../categories/class/api_category.class.php | 39 ++++++++++++++++++- htdocs/commande/class/api_commande.class.php | 3 +- htdocs/societe/class/api_thirdparty.class.php | 3 +- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/class/api_category.class.php b/htdocs/categories/class/api_category.class.php index d66875185a4..71e727aac4a 100644 --- a/htdocs/categories/class/api_category.class.php +++ b/htdocs/categories/class/api_category.class.php @@ -18,6 +18,7 @@ use Luracast\Restler\RestException; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; /** * API class for category object @@ -276,6 +277,7 @@ class CategoryApi extends DolibarrApi /** * Get categories for a customer * + * @param int $cusid Customer id filter * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -285,9 +287,44 @@ class CategoryApi extends DolibarrApi * * @url GET /customer/{cusid}/categories */ - function getListCustomerCategories($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $cusid) { + function getListCustomerCategories($cusid, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { return $this->getListForItem('customer', $sortfield, $sortorder, $limit, $page, $cusid); } + + /** + * Add category to customer + * + * @param int $cusid Id of customer + * @param int $catid Id of category + * + * @return mixed + * + * @url GET /customer/{cusid}/addCategory/{catid} + */ + + function addCustomerCategory($cusid,$catid) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $customer = new Client($this->db); + $customer->fetch($cusid); + if( ! $customer ) { + throw new RestException(404, 'customer not found'); + } + $result = $this->category->fetch($catid); + if( ! $result ) { + throw new RestException(404, 'category not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe',$customer->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->category->add_type($customer,'customer'); + return $customer; + } /** * Get supplier categories list diff --git a/htdocs/commande/class/api_commande.class.php b/htdocs/commande/class/api_commande.class.php index 8ed6de4dda2..c449210de73 100644 --- a/htdocs/commande/class/api_commande.class.php +++ b/htdocs/commande/class/api_commande.class.php @@ -98,6 +98,7 @@ class CommandeApi extends DolibarrApi * Get a list of orders * * @param int $mode Use this param to filter list + * @param string $societe Societe filter field * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -202,7 +203,7 @@ class CommandeApi extends DolibarrApi * * @url POST order/ * - * @return string ID of commande + * @return int ID of commande */ function post($request_data = NULL) { diff --git a/htdocs/societe/class/api_thirdparty.class.php b/htdocs/societe/class/api_thirdparty.class.php index 430dc1aaf0a..9c65d08ac43 100644 --- a/htdocs/societe/class/api_thirdparty.class.php +++ b/htdocs/societe/class/api_thirdparty.class.php @@ -147,6 +147,7 @@ class ThirdpartyApi extends DolibarrApi * @param int $mode Set to 1 to show only customers * Set to 2 to show only prospects * Set to 3 to show only those are not customer neither prospect + * @param Text $email Search by email filter * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -369,7 +370,7 @@ class ThirdpartyApi extends DolibarrApi * Delete thirdparty * * @param int $id Thirparty ID - * @return integer + * @return type * * @url DELETE thirdparty/{id} * @url DELETE customer/{id} From 11292410e950e770ba906f621b6f693e5e50e9ae Mon Sep 17 00:00:00 2001 From: nka11 Date: Sun, 10 Apr 2016 14:23:29 +0200 Subject: [PATCH 29/78] Fix coding style errors --- htdocs/categories/class/api_category.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/categories/class/api_category.class.php b/htdocs/categories/class/api_category.class.php index 71e727aac4a..5e558ddc486 100644 --- a/htdocs/categories/class/api_category.class.php +++ b/htdocs/categories/class/api_category.class.php @@ -301,7 +301,6 @@ class CategoryApi extends DolibarrApi * * @url GET /customer/{cusid}/addCategory/{catid} */ - function addCustomerCategory($cusid,$catid) { if(! DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); From b7275edfb8db5a92e19a901ac61b22a0bd107370 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Apr 2016 14:24:31 +0200 Subject: [PATCH 30/78] FIX #4989 --- htdocs/admin/dict.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index bc56f13cc66..a5a3139353a 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -232,7 +232,7 @@ $tabfield[21]= "code,label"; $tabfield[22]= "code,label"; $tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[24]= "code,label"; -$tabfield[25]= "label,type_template,position,topic,content"; +$tabfield[25]= "label,type_template,private,position,topic,content"; $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newByMonth,country_id,country"; @@ -264,7 +264,7 @@ $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[25]= "label,type_template,private,position,topic,content"; $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newByMonth,country"; @@ -585,7 +585,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=0; setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors'); } - + // Clean some parameters if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 @@ -685,7 +685,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - + print $sql; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); @@ -1330,7 +1330,7 @@ if ($id) if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; } $canbemodified=$iserasable; if ($obj->code == 'RECEP') $canbemodified=1; - + $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; // Favorite From 23bb2eaf8a4e1be3fdf22db1d4b05324bf6287a3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Apr 2016 14:27:17 +0200 Subject: [PATCH 31/78] remove debug --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index a5a3139353a..5e9fc895f0b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -685,7 +685,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - print $sql; + dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); From 8035742779d1b7f9c4afe90fb6b6fd44a3a9aa2e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Apr 2016 14:52:22 +0200 Subject: [PATCH 32/78] FIX fetchAllEMailTemplate --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index bc185ef6d71..f8f6afcf1ff 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -334,7 +334,7 @@ class FormMail extends Form $out.= '   '; $out.= ''; } - + $out.= ''."\n"; @@ -894,7 +894,7 @@ class FormMail extends Form $line->id=$obj->rowid; $line->label=$obj->label; $line->topic=$obj->topic; - $line->content=$obj->lacontentbel; + $line->content=$obj->content; $line->lang=$obj->lang; $this->lines_model[]=$line; } From 791df0c9ea4e657c2d80c51d91b9c41886463551 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Apr 2016 17:27:34 +0200 Subject: [PATCH 33/78] FIX: correct display of minimum buying price --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 344fa3ffa56..50613103848 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -540,7 +540,7 @@ class ProductFournisseur extends Product { global $langs; $langs->load("suppliers"); - $out=($showunitprice?price($this->fourn_unitprice).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); return $out; } From 983b2c9a210c11a56f7af7376686afaef70ba8b6 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Apr 2016 17:40:47 +0200 Subject: [PATCH 34/78] FIX: real min buying price --- htdocs/product/composition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 89760dc66ba..10d50acebe0 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -354,7 +354,7 @@ if ($id > 0 || ! empty($ref)) else { print $langs->trans("NotDefined"); $notdefined++; $atleastonenotdefined++; } } print ''; - $totalline=price2num($value['nb'] * $product_fourn->fourn_unitprice, 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges), 'MT'); $total+=$totalline; print ''; if (! empty($conf->stock->enabled)) print ''; // Real stock From 292373cf8401f190ccc7269838d0e0efdff5d0c6 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Apr 2016 17:43:10 +0200 Subject: [PATCH 35/78] forgot new discount field --- htdocs/product/composition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 10d50acebe0..6cb6424bdc4 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -354,7 +354,7 @@ if ($id > 0 || ! empty($ref)) else { print $langs->trans("NotDefined"); $notdefined++; $atleastonenotdefined++; } } print ''; - $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges), 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT'); $total+=$totalline; print ''; if (! empty($conf->stock->enabled)) print ''; // Real stock From 1fdcd0e859642b400dbd4e2bea344b5882f6b25a Mon Sep 17 00:00:00 2001 From: nka11 Date: Mon, 11 Apr 2016 18:07:02 +0200 Subject: [PATCH 36/78] Fixed bugs in order api. Added method for posting new lines in order --- htdocs/commande/class/api_commande.class.php | 84 +++++++++++++++++--- 1 file changed, 74 insertions(+), 10 deletions(-) diff --git a/htdocs/commande/class/api_commande.class.php b/htdocs/commande/class/api_commande.class.php index c449210de73..a8479900aad 100644 --- a/htdocs/commande/class/api_commande.class.php +++ b/htdocs/commande/class/api_commande.class.php @@ -212,19 +212,84 @@ class CommandeApi extends DolibarrApi } // Check mandatory fields $result = $this->_validate($request_data); - + foreach($request_data as $field => $value) { $this->commande->$field = $value; } + if (isset($request_data["lines"])) { + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object)$line); + } + $this->commande->lines = $lines; + } if(! $this->commande->create(DolibarrApiAccess::$user) ) { throw new RestException(401); } - return $this->commande->ref; + return $this->commande->id; + } + /** + * Add a line to given order + * + * + * @param int $id Id of commande to update + * @param array $request_data Orderline data + * + * @url POST order/{id}/line + * + * @return int + */ + function postLine($id, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } + + $result = $this->commande->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Commande not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object)$request_data; + $updateRes = $this->commande->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->info_bits, + $request_data->fk_remise_except, + 'HT', + 0, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->rang, + $request_data->special_code, + $fk_parent_line, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->array_options, + $request_data->fk_unit, + $this->element, + $request_data->id + ); + + if ($updateRes > 0) { + return $this->get($id); + } + return false; } /** - * Update order + * Update order general fields (don't touch lines of order) * * @param int $id Id of commande to update * @param array $request_data Datas @@ -233,11 +298,10 @@ class CommandeApi extends DolibarrApi * * @return int */ - function put($id, $request_data = NULL) - { - if(! DolibarrApiAccess::$user->rights->commande->creer) { - throw new RestException(401); - } + function put($id, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } $result = $this->commande->fetch($id); if( ! $result ) { @@ -247,13 +311,12 @@ class CommandeApi extends DolibarrApi if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { $this->commande->$field = $value; } if($this->commande->update($id, DolibarrApiAccess::$user,1,'','','update')) - return $this->get ($id); + return $this->get($id); return false; } @@ -346,6 +409,7 @@ class CommandeApi extends DolibarrApi if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $commande[$field] = $data[$field]; + } return $commande; } From e5a447c14885997eab64ebb3ad40062b55005c8a Mon Sep 17 00:00:00 2001 From: nka11 Date: Mon, 11 Apr 2016 22:41:35 +0200 Subject: [PATCH 37/78] Adding more line features (PUT, DELETE, POST) --- htdocs/commande/class/api_commande.class.php | 122 ++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/api_commande.class.php b/htdocs/commande/class/api_commande.class.php index a8479900aad..7d4df239c85 100644 --- a/htdocs/commande/class/api_commande.class.php +++ b/htdocs/commande/class/api_commande.class.php @@ -229,6 +229,37 @@ class CommandeApi extends DolibarrApi return $this->commande->id; } + /** + * Get lines of an order + * + * + * @param int $id Id of order + * @param array $request_data Orderline data + * + * @url GET order/{id}/line/list + * + * @return int + */ + function getLines($id) { + if(! DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } + + $result = $this->commande->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Commande not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->commande->getLinesArray(); + $result = array(); + foreach ($this->commande->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } /** * Add a line to given order * @@ -283,13 +314,102 @@ class CommandeApi extends DolibarrApi ); if ($updateRes > 0) { + return $this->get($id)->line->rowid; + + } + return false; + } + /** + * Update a line to given order + * + * + * @param int $id Id of commande to update + * @param int $lineid Id of line to update + * @param array $request_data Orderline data + * + * @url PUT order/{id}/line/{lineid} + * + * @return object + */ + function putLine($id, $lineid, $request_data = NULL) { + if(! DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } + + $result = $this->commande->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Commande not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object)$request_data; + $updateRes = $this->commande->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->fk_unit + ); + + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; + } + /** + * Delete a line to given order + * + * + * @param int $id Id of commande to update + * @param int $lineid Id of line to delete + * + * @url DELETE order/{id}/line/{lineid} + * + * @return int + */ + function delLine($id, $lineid) { + if(! DolibarrApiAccess::$user->rights->commande->creer) { + throw new RestException(401); + } + + $result = $this->commande->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Commande not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object)$request_data; + $updateRes = $this->commande->deleteline($lineid); + if ($updateRes == 1) { return $this->get($id); } return false; } /** - * Update order general fields (don't touch lines of order) + * Update order general fields (won't touch lines of order) * * @param int $id Id of commande to update * @param array $request_data Datas From 9ced1dc008f5647f39db6aad1407845ef66df043 Mon Sep 17 00:00:00 2001 From: nka11 Date: Mon, 11 Apr 2016 23:27:43 +0200 Subject: [PATCH 38/78] fixing some style and renaming Account to User API --- htdocs/commande/class/api_commande.class.php | 16 ++--- ...i_account.class.php => api_user.class.php} | 66 +++++++++---------- 2 files changed, 39 insertions(+), 43 deletions(-) rename htdocs/user/class/{api_account.class.php => api_user.class.php} (73%) diff --git a/htdocs/commande/class/api_commande.class.php b/htdocs/commande/class/api_commande.class.php index 7d4df239c85..248cbbcabc4 100644 --- a/htdocs/commande/class/api_commande.class.php +++ b/htdocs/commande/class/api_commande.class.php @@ -98,16 +98,16 @@ class CommandeApi extends DolibarrApi * Get a list of orders * * @param int $mode Use this param to filter list - * @param string $societe Societe filter field * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number + * @param string $societe Societe filter field * * @url GET /order/list * @return array Array of order objects */ - function getList($mode=0, $societe = "", $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { + function getList($mode=0, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $societe = 0) { global $db, $conf; $obj_ret = array(); @@ -191,8 +191,8 @@ class CommandeApi extends DolibarrApi * @url GET /thirdparty/{socid}/order/list * @return array Array of order objects */ - function getListForSoc($socid = "") { - return getList(0,$socid); + function getListForSoc($socid = 0) { + return getList(0,"s.rowid","ASC",0,0,$socid); } @@ -219,7 +219,7 @@ class CommandeApi extends DolibarrApi if (isset($request_data["lines"])) { $lines = array(); foreach ($request_data["lines"] as $line) { - array_push($lines, (object)$line); + array_push($lines, (object) $line); } $this->commande->lines = $lines; } @@ -284,7 +284,7 @@ class CommandeApi extends DolibarrApi if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object)$request_data; + $request_data = (object) $request_data; $updateRes = $this->commande->addline( $request_data->desc, $request_data->subprice, @@ -344,7 +344,7 @@ class CommandeApi extends DolibarrApi if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object)$request_data; + $request_data = (object) $request_data; $updateRes = $this->commande->updateline( $lineid, $request_data->desc, @@ -400,7 +400,7 @@ class CommandeApi extends DolibarrApi if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object)$request_data; + $request_data = (object) $request_data; $updateRes = $this->commande->deleteline($lineid); if ($updateRes == 1) { return $this->get($id); diff --git a/htdocs/user/class/api_account.class.php b/htdocs/user/class/api_user.class.php similarity index 73% rename from htdocs/user/class/api_account.class.php rename to htdocs/user/class/api_user.class.php index 956584d9292..d09785d3ccb 100644 --- a/htdocs/user/class/api_account.class.php +++ b/htdocs/user/class/api_user.class.php @@ -27,7 +27,7 @@ use Luracast\Restler\RestException; * @class DolibarrApiAccess {@requires user,external} * */ -class AccountApi extends DolibarrApi +class UserApi extends DolibarrApi { /** * @@ -38,68 +38,66 @@ class AccountApi extends DolibarrApi ); /** - * @var User $account {@type User} + * @var User $user {@type User} */ - public $account; + public $useraccount; /** * Constructor * - * @url account/ + * @url user/ * */ function __construct() { global $db, $conf; $this->db = $db; - $this->account = new User($this->db); + $this->useraccount = new User($this->db); } /** - * Get properties of an account object + * Get properties of an user object * - * Return an array with account informations + * Return an array with user informations * - * @param int $id ID of account + * @param int $id ID of user * @return array|mixed data without useless information * - * @url GET account/{user} + * @url GET user/{id} * @throws RestException */ function get($id) { - //if (!DolibarrApiAccess::$user->rights->user->lire) - //{ + //if (!DolibarrApiAccess::$user->rights->user->user->lire) { //throw new RestException(401); //} - $result = $this->account->fetch($id); + $result = $this->useraccount->fetch($id); if (!$result) { throw new RestException(404, 'User not found'); } - if (!DolibarrApi::_checkAccessToResource('user', $this->account->id, 'user')) + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } - return $this->_cleanObjectDatas($this->account); + return $this->_cleanObjectDatas($this->useraccount); } /** - * Create account object from contact + * Create useraccount object from contact * * @param int $contactid Id of contact * @param array $request_data Request datas - * @return int ID of account + * @return int ID of user * - * @url POST /contact/{contactid}/createAccount + * @url POST /contact/{contactid}/createUser */ function createFromContact($contactid, $request_data = NULL) { - //if (!DolibarrApiAccess::$user->rights->user->creer) - //{ + //if (!DolibarrApiAccess::$user->rights->user->user->creer) { //throw new RestException(401); //} - // + if (!isset($request_data["login"])) throw new RestException(400, "login field missing"); if (!isset($request_data["password"])) @@ -119,12 +117,12 @@ class AccountApi extends DolibarrApi // Check mandatory fields $login = $request_data["login"]; $password = $request_data["password"]; - $result = $this->account->create_from_contact($contact,$login,$password); + $result = $this->useraccount->create_from_contact($contact,$login,$password); if ($result <= 0) { throw new RestException(500, "User not created"); } // password parameter not used in create_from_contact - $this->account->setPassword($this->account,$password); + $this->useraccount->setPassword($this->useraccount,$password); return $result; } @@ -135,31 +133,30 @@ class AccountApi extends DolibarrApi * @param array $request_data Datas * @return int * - * @url PUT account/{id} + * @url PUT user/{id} */ function put($id, $request_data = NULL) { - //if (!DolibarrApiAccess::$user->rights->user->creer) - //{// + //if (!DolibarrApiAccess::$user->rights->user->user->creer) { //throw new RestException(401); //} - $result = $this->account->fetch($id); + $result = $this->useraccount->fetch($id); if (!$result) { throw new RestException(404, 'Account not found'); } - if (!DolibarrApi::_checkAccessToResource('user', $this->account->id, 'user')) + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { - $this->account->$field = $value; + $this->useraccount->$field = $value; } - if ($this->account->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) + if ($this->useraccount->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) return $this->get($id); return false; @@ -171,25 +168,24 @@ class AccountApi extends DolibarrApi * @param int $id Account ID * @return array * - * @url DELETE account/{id} + * @url DELETE user/{id} */ function delete($id) { - //if (!DolibarrApiAccess::$user->rights->user->supprimer) - //{ + //if (!DolibarrApiAccess::$user->rights->user->user->supprimer) { //throw new RestException(401); //} - $result = $this->account->fetch($id); + $result = $this->useraccount->fetch($id); if (!$result) { throw new RestException(404, 'User not found'); } - if (!DolibarrApi::_checkAccessToResource('user', $this->account->id, 'user')) + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } - return $this->account->delete($id); + return $this->useraccount->delete($id); } /** From 0dd25a7e7042f9dcd884c75ccc16daf254ea4f0b Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 12 Apr 2016 09:39:48 +0200 Subject: [PATCH 39/78] add new filter in GROUP BY clause --- htdocs/compta/stats/cabyprodserv.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 7e5a194c0e7..ca58ff334b5 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -222,7 +222,7 @@ if ($modecompta == 'CREANCES-DETTES') $sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; } $sql.= " AND f.entity = ".$conf->entity; - $sql.= " GROUP BY p.rowid, p.ref, p.label"; + $sql.= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type"; $sql.= $db->order($sortfield,$sortorder); dol_syslog("cabyprodserv", LOG_DEBUG); From 872c99afe951b1ed23611681c0f68e73625dc5b3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 12 Apr 2016 11:35:39 +0200 Subject: [PATCH 40/78] FIX Hook resprint be printed --- htdocs/core/tpl/objectline_create.tpl.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 31ad9716155..71d34ac4cd4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -32,7 +32,7 @@ $usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) { $usemargins=1; } @@ -193,11 +193,17 @@ else { { $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int')); $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } } if (is_object($hookmanager) && ! empty($senderissupplier)) { $parameters=array('htmlname'=>'addproduct'); $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } } @@ -476,7 +482,7 @@ jQuery(document).ready(function() { $("#select_type").change(function() { setforfree(); - if (jQuery('#select_type').val() >= 0) + if (jQuery('#select_type').val() >= 0) { /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ jQuery('#dp_desc').focus(); @@ -582,7 +588,7 @@ jQuery(document).ready(function() { /* To set focus */ - if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) + if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) { /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ jQuery('#dp_desc').focus(); From 56c64f22bec579fbe8d67d8e0142588725451017 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 13:30:47 +0200 Subject: [PATCH 41/78] Prepare menu icon to hide/show left menu --- htdocs/theme/eldy/img/menus/menu.png | Bin 0 -> 166 bytes htdocs/theme/eldy/img/menus_black/menu.png | Bin 0 -> 101 bytes htdocs/theme/md/img/menu.png | Bin 0 -> 166 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/theme/eldy/img/menus/menu.png create mode 100644 htdocs/theme/eldy/img/menus_black/menu.png create mode 100644 htdocs/theme/md/img/menu.png diff --git a/htdocs/theme/eldy/img/menus/menu.png b/htdocs/theme/eldy/img/menus/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..e8ef108b1275503b5da65e98c326ba7c89c4c9ac GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}trX+877l!}s{b%+Ad7K3vk;M!Q z+`=Ht$S`Y;1W=H@#M9T6{Q(OPx2#;w2eBhSA#+a`$B>A_Z!a$t1RBR+c;i5)Gg-^b@sk}t>*8+f6Ol&*dgeEykch)?FB=LnFmNz${AJE7 yXCby@2~%AbQ%$h9@C^13%#42=80-ZY^s?9ex4rLXcYi8SAA_f>pUXO@geCw|yc$0M literal 0 HcmV?d00001 diff --git a/htdocs/theme/md/img/menu.png b/htdocs/theme/md/img/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..e8ef108b1275503b5da65e98c326ba7c89c4c9ac GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}trX+877l!}s{b%+Ad7K3vk;M!Q z+`=Ht$S`Y;1W=H@#M9T6{Q(OPx2#;w2eBhSA#+a`$B>A_Z!a$t1RBR+c;i5)Gg-^b@sk}t>*8+f6Ol&*dgeEy Date: Tue, 12 Apr 2016 13:38:41 +0200 Subject: [PATCH 42/78] Removed hidden option MAIN_MENU_USE_JQUERY_LAYOUT. This feature will be implemented with pure CSS/Jquery so no more need of not maintained external library. --- htdocs/admin/menus/other.php | 33 -------------- htdocs/main.inc.php | 79 ++------------------------------- htdocs/theme/eldy/style.css.php | 4 +- htdocs/theme/md/style.css.php | 4 +- 4 files changed, 8 insertions(+), 112 deletions(-) diff --git a/htdocs/admin/menus/other.php b/htdocs/admin/menus/other.php index 73dc0fe3b85..471edf58e79 100644 --- a/htdocs/admin/menus/other.php +++ b/htdocs/admin/menus/other.php @@ -50,25 +50,11 @@ else if ($action == 'disable_hidemenu') exit; } -if ($action == 'activate_layoutmenu') -{ - dolibarr_set_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT", '1','chaine',0,'',$conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; -} -else if ($action == 'disable_layoutmenu') -{ - dolibarr_del_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT",$conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; -} - /* * View */ - llxHeader('',$langs->trans("Setup")); print load_fiche_titre($langs->trans("Menus"),'','title_setup'); @@ -119,25 +105,6 @@ else print ""; print ''; -// Use a flip-hide menu -if (isset($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL > 1) -{ - $var=!$var; - print ""; - print ''; - print '"; - print ''; -} - print '
'.($notdefined?'':price($totalline,'','',0,0,-1,$conf->currency)).''.$langs->trans("Stock").': '.$value['stock'].''.($notdefined?'':price($totalline,'','',0,0,-1,$conf->currency)).''.$langs->trans("Stock").': '.$value['stock'].'
'.$langs->trans("MenuUseLayout").''; - if (empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) - { - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; - } - else - { - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; - } - print "
'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8652af27d82..697b2ab9ab9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1033,13 +1033,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs else print ''."\n"; // JQuery print ''."\n"; // Tooltip print ''."\n"; // JNotify - /*if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) || (defined('REQUIRE_JQUERY_FILEUPLOAD') && constant('REQUIRE_JQUERY_FILEUPLOAD'))) // jQuery fileupload - { - print ''."\n"; - }*/ if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES) || (defined('REQUIRE_JQUERY_DATATABLES') && constant('REQUIRE_JQUERY_DATATABLES'))) // jQuery datatables { - //print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -1131,11 +1126,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs else print ''."\n"; print ''."\n"; print ''."\n"; - // jQuery Layout - if (empty($conf->dol_use_jmobile) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) || defined('REQUIRE_JQUERY_LAYOUT')) - { - print ''."\n"; - } // jQuery jnotify if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) { @@ -1374,60 +1364,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if ($conf->use_javascript_ajax) { - if (empty($conf->dol_use_jmobile) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) - { - print '' . "\n"; - } - // Raven.js for client-side Sentry logging support if (array_key_exists('mod_syslog_sentry', $conf->loghandlers) && ! empty($conf->global->SYSLOG_SENTRY_DSN)) { @@ -1448,8 +1384,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a */ print "\n".''."\n"; - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; - if (empty($conf->dol_hide_topmenu)) { print '
'; @@ -1579,11 +1513,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a //unset($form); } - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "
\n"; print '
'; print "\n\n"; - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'; + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'; } @@ -1616,8 +1549,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra // Instantiate hooks of thirdparty module $hookmanager->initHooks(array('searchform','leftblock')); - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n".''."\n".'
'."\n"; - else print "\n".''."\n".'
'."\n"; + print "\n".''."\n".'
'."\n"; print "\n"; @@ -1779,8 +1711,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra $reshook=$hookmanager->executeHooks('printLeftBlock',$parameters); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; - else print '
'; // End div id="id-left" + print '
'; // End div id="id-left" } print "\n"; @@ -1800,7 +1731,6 @@ function main_area($title='') { global $conf, $langs; - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; if (empty($conf->dol_hide_leftmenu)) print '
'; print "\n"; @@ -1944,7 +1874,6 @@ if (! function_exists("llxFooter")) print '
'."\n"; if (! empty($conf->dol_use_jmobile)) print '
'; // end data-role="page" - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; if (empty($conf->dol_hide_leftmenu)) print '
'; // End div id-right print "\n"; @@ -1953,7 +1882,7 @@ if (! function_exists("llxFooter")) printCommonFooter($zone); //var_dump($langs); // Uncommment to see the property _tab_loaded to see which language file were loaded - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; // End div container + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'."\n"; // End div container if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b772f741219..7454229aec0 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -646,7 +646,7 @@ td.showDragHandle { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'6':'20'):'24')); ?>px; + margin-: px; margin-: dol_optimize_smallscreen)?'12':'6')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> } @@ -683,7 +683,7 @@ div.ficheaddleft { @media only screen and (max-width: 900px) { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'6':'20'):'24')); ?>px; + margin-: px; margin-: px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9644232d2c6..78a8eaf79b2 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -699,7 +699,7 @@ td.showDragHandle { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'4':'20'):'24')); ?>px; + margin-: px; margin-: dol_optimize_smallscreen)?'16':'4')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> margin-bottom: 15px; @@ -737,7 +737,7 @@ div.ficheaddleft { @media only screen and (max-width: 900px) { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'4':'20'):'24')); ?>px; + margin-: px; margin-: px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> margin-bottom: 15px; From 357877b1fe1c3e90cae0feeba5e7af7cf128205e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 14:10:27 +0200 Subject: [PATCH 43/78] Debug multicurrency and clean properties of some modules --- htdocs/admin/multicurrency.php | 6 ++-- htdocs/comm/propal.php | 10 +++--- htdocs/commande/card.php | 6 ++-- htdocs/compta/facture.php | 6 ++-- htdocs/contrat/card.php | 1 + htdocs/core/class/html.form.class.php | 31 +++++++++++++------ htdocs/core/modules/modCategorie.class.php | 3 +- .../modules/modDocumentGeneration.class.php | 2 +- htdocs/core/modules/modExport.class.php | 2 +- htdocs/core/modules/modFckeditor.class.php | 1 + htdocs/core/modules/modImport.class.php | 2 +- htdocs/core/modules/modLabel.class.php | 1 + .../core/modules/modMultiCurrency.class.php | 4 +-- htdocs/core/modules/modWebsites.class.php | 2 +- htdocs/fourn/commande/card.php | 5 +-- htdocs/fourn/facture/card.php | 5 +-- .../install/mysql/migration/3.9.0-4.0.0.sql | 3 +- .../mysql/tables/llx_multicurrency_rate.sql | 3 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/receiptprinter.lang | 2 +- .../class/multicurrency.class.php | 2 ++ htdocs/supplier_proposal/card.php | 6 ++-- 22 files changed, 66 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index b1ad347d8b7..b77606a60ed 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -136,7 +136,7 @@ if ($resql) * View */ -$page_name = "MultiCurrency"; +$page_name = "MultiCurrencySetup"; llxHeader('', $langs->trans($page_name)); @@ -212,7 +212,7 @@ print ''; print '
'; print ''; print ''; -print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY')); +print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY'), $conf->global->MULTICURRENCY_MODIFY_RATE_APPLICATION); print ''; print '
'; print ''; @@ -230,6 +230,7 @@ print '' print ''; print ''; +/* This property seems not used in code, so i comment it $var=!$var; print ''; print ''.$langs->transnoentitiesnoconv("multicurrency_currencyFromToRate").''; @@ -242,6 +243,7 @@ print ''; print ''; print ''; +*/ print ''; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index dea894a0258..d05f9078828 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -911,6 +911,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1040,6 +1041,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1325,7 +1327,7 @@ if ($action == 'create') } } else { print ''; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 1); + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { @@ -1465,7 +1467,7 @@ if ($action == 'create') print ''.fieldLabel('Currency','multicurrency_code').''; print ''; $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)); - print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 1); print ''; } @@ -1978,9 +1980,9 @@ if ($action == 'create') print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9b5c29f55db..db80893f426 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -833,6 +833,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -963,6 +964,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -2205,9 +2207,9 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 00498b870a7..491c4ca041a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1522,6 +1522,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1682,6 +1683,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -3516,9 +3518,9 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index b38787a4067..36c79c0f7c5 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -621,6 +621,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 082f362458b..4c32664630f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -902,7 +902,7 @@ class Form * @param string $selected Preselected type * @param string $htmlname Name of field in form * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)') - * @param string $showempty Add an empty field (Can be '1' or text to use on empty line like 'SelectThirdParty') + * @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty') * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) @@ -3779,7 +3779,7 @@ class Form print ''; print ''; print ''; print ''; print '
'; - print $this->selectMultiCurrency($selected,$htmlname); + print $this->selectMultiCurrency($selected, $htmlname, 1); print '
'; @@ -3797,11 +3797,13 @@ class Form * @param string $page Page * @param double $rate Current rate * @param string $htmlname Name of select html field + * @param string $currency Currency code to explain the rate * @return void */ - function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx') + function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx', $currency='') { - global $langs; + global $langs, $mysoc, $conf; + if ($htmlname != "none") { print '
'; @@ -3816,7 +3818,15 @@ class Form } else { - print !empty($rate) ? price(price2num($rate), 1, $langs) : 1; + if (! empty($rate)) + { + print price($rate, 1, $langs, 1, 0); + if ($currency && $rate != 1) print '   ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')'; + } + else + { + print 1; + } } } @@ -4030,17 +4040,17 @@ class Form * @param integer $useempty 1=Add empty line * @return string */ - function selectMultiCurrency($selected='',$htmlname='multicurrency_code', $useempty=0) + function selectMultiCurrency($selected='', $htmlname='multicurrency_code', $useempty=0) { global $db,$conf,$langs,$user; - $langs->loadCacheCurrencies(''); + $langs->loadCacheCurrencies(''); // Load ->cache_currencies $TCurrency = array(); $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; + $sql.= " WHERE entity IN ('".getEntity('mutlicurrency')."')"; $resql = $db->query($sql); - if ($resql) { while ($obj = $db->fetch_object($resql)) $TCurrency[$obj->code] = $obj->code; @@ -4048,14 +4058,14 @@ class Form $out=''; $out.= ''; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index ad4c2bba16a..17141b6200d 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -45,6 +45,7 @@ class modCategorie extends DolibarrModules $this->numero = 1780; $this->family = "technic"; + $this->module_position = 20; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des categories (produits, clients, fournisseurs...)"; @@ -53,7 +54,7 @@ class modCategorie extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 2; + $this->special = 0; $this->picto = 'category'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index 9111ec11099..0648eb8bf0b 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -45,7 +45,7 @@ class modDocumentGeneration extends DolibarrModules $this->numero = 1520; $this->family = "technic"; - $this->module_position = 10000; + $this->module_position = 80; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Direct mail document generation"; diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index cb3d104e096..e8a6baa8509 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -44,7 +44,7 @@ class modExport extends DolibarrModules $this->numero = 240; $this->family = "technic"; - $this->module_position = 520; + $this->module_position = 72; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Outils d'exports de donnees Dolibarr (via un assistant)"; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 4735b0811a3..31b3fafff16 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -45,6 +45,7 @@ class modFckeditor extends DolibarrModules $this->numero = 2000; $this->family = "technic"; + $this->module_position = 20; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Editeur WYSIWYG"; diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index 63af9dc9064..8f3faad9bd1 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -44,7 +44,7 @@ class modImport extends DolibarrModules $this->numero = 250; $this->family = "technic"; - $this->module_position = 510; + $this->module_position = 70; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Outils d'imports de donnees Dolibarr (via un assistant)"; diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index 0b282584261..05e98d36454 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -44,6 +44,7 @@ class modLabel extends DolibarrModules $this->numero = 60; $this->family = "technic"; + $this->module_position = 80; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des etiquettes"; diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 48ce8bc3bc0..7ae613edd49 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -52,9 +52,9 @@ class modMultiCurrency extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "financial"; + $this->family = "technic"; // Module position in the family - $this->module_position = 555; + $this->module_position = 40; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); diff --git a/htdocs/core/modules/modWebsites.class.php b/htdocs/core/modules/modWebsites.class.php index 8e019fabed8..e3b500b0e0d 100644 --- a/htdocs/core/modules/modWebsites.class.php +++ b/htdocs/core/modules/modWebsites.class.php @@ -46,7 +46,7 @@ class modWebsites extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page $this->family = "portal"; - $this->module_position = 20; + $this->module_position = 50; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the public website with CMS features"; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8bff36e159e..59bc805a120 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -472,6 +472,7 @@ if (empty($reshook)) unset($_POST['remise_percent']); unset($_POST['pu']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['label']); @@ -2027,9 +2028,9 @@ elseif (! empty($object->id)) print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d14dd97e6b3..08748bef416 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -830,6 +830,7 @@ if (empty($reshook)) unset($_POST['remise_percent']); unset($_POST['pu']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['label']); @@ -2053,9 +2054,9 @@ else print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 15de62fb3e8..8296aa82e74 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -190,8 +190,7 @@ CREATE TABLE llx_multicurrency_rate rowid integer AUTO_INCREMENT PRIMARY KEY, date_sync datetime DEFAULT NULL, rate double NOT NULL DEFAULT 0, - fk_multicurrency integer NOT NULL, - entity integer NOT NULL DEFAULT 1 + fk_multicurrency integer NOT NULL ) ENGINE=innodb; ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer; diff --git a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql index e6b90382dcd..333f5deab52 100644 --- a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql +++ b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql @@ -22,6 +22,5 @@ CREATE TABLE llx_multicurrency_rate rowid integer AUTO_INCREMENT PRIMARY KEY, date_sync datetime DEFAULT NULL, rate double NOT NULL DEFAULT 0, - fk_multicurrency integer NOT NULL, - entity integer DEFAULT 1 + fk_multicurrency integer NOT NULL ) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3468dc43eee..b37083ca091 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -99,6 +99,7 @@ AntiVirusParamExample= Example for ClamWin: --database="C:\Program Files (x86)\C ComptaSetup=Accounting module setup UserSetup=User management setup MenuSetup=Menu management setup +MultiCurrencySetup=Multi-currency setup MenuLimits=Limits and accuracy MenuIdParent=Parent menu ID DetailMenuIdParent=ID of parent menu (empty for a top menu) diff --git a/htdocs/langs/en_US/receiptprinter.lang b/htdocs/langs/en_US/receiptprinter.lang index 7b52f072eaf..189a8f25e38 100644 --- a/htdocs/langs/en_US/receiptprinter.lang +++ b/htdocs/langs/en_US/receiptprinter.lang @@ -5,7 +5,7 @@ PrinterUpdated=Printer %s updated PrinterDeleted=Printer %s deleted TestSentToPrinter=Test Sent To Printer %s ReceiptPrinter=Receipt printers -ReceiptPrinterDesc=Setup of printers +ReceiptPrinterDesc=Setup of receipt printers ReceiptPrinterTemplateDesc=Setup of Templates ReceiptPrinterTypeDesc=Description of Receipt Printer's type ReceiptPrinterProfileDesc=Description of Receipt Printer's Profile diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index fd6da3816ea..834d5b38605 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -471,7 +471,9 @@ class MultiCurrency extends CommonObject { $sql = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; + // FIXME Is this comptible with SQL ? $sql.= ' WHERE m.code = "'.$db->escape($code).'" AND mc.date_sync >= ALL (SELECT date_sync FROM '.MAIN_DB_PREFIX.'multicurrency_rate)'; + $sql.= " AND m.entity IN '".getEntity('multicurrency', 1)."'"; $resql = $db->query($sql); if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); else return array(0, 1); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index be07d022fdb..9101b6efda2 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -717,6 +717,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -841,6 +842,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1549,9 +1551,9 @@ if ($action == 'create') print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } From df8bbaee3410864e1db7c35c31fb2ea18395a305 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 18:24:35 +0200 Subject: [PATCH 44/78] Add icone for website module --- htdocs/theme/eldy/style.css.php | 7 ++++++- htdocs/theme/md/style.css.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 7454229aec0..ce97dd1c14f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1021,6 +1021,10 @@ div.mainmenu.tools { background-image: url(); } +div.mainmenu.websites { + background-image: url(); +} + 'name of class for div') @@ -1040,7 +1044,8 @@ foreach($conf->modules as $val) $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices'); +// Put here list of menu entries when the div.mainmenu.menuentry was previously defined +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 78a8eaf79b2..8997231230f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1072,6 +1072,10 @@ div.mainmenu.tools { background-image: url(); } +div.mainmenu.websites { + background-image: url(); +} + 'name of class for div') @@ -1091,7 +1095,8 @@ foreach($conf->modules as $val) $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices'); +// Put here list of menu entries when the div.mainmenu.menuentry was previously defined +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; From 87702f89fc7b9dca28972d376b872f468d20af28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 19:17:50 +0200 Subject: [PATCH 45/78] Work on website module --- htdocs/websites/class/website.class.php | 640 ++++++++++++++++++++++++ htdocs/websites/index.php | 64 ++- 2 files changed, 694 insertions(+), 10 deletions(-) create mode 100644 htdocs/websites/class/website.class.php diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php new file mode 100644 index 00000000000..46a0bfe495a --- /dev/null +++ b/htdocs/websites/class/website.class.php @@ -0,0 +1,640 @@ + + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file websites/website.class.php + * \ingroup websites + * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * Put some comments here + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class Website + * + * Put here description of your class + * @see CommonObject + */ +class Website extends CommonObject +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'website'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'website'; + + /** + * @var WebsiteLine[] Lines + */ + public $lines = array(); + + /** + */ + + public $entity; + public $shortname; + public $description; + public $status; + public $date_creation = ''; + public $date_modification = ''; + public $tms = ''; + + /** + */ + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + return 1; + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + // Clean parameters + + if (isset($this->entity)) { + $this->entity = trim($this->entity); + } + if (isset($this->shortname)) { + $this->shortname = trim($this->shortname); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->status)) { + $this->status = trim($this->status); + } + + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; + + $sql.= 'entity,'; + $sql.= 'shortname,'; + $sql.= 'description,'; + $sql.= 'status,'; + $sql.= 'date_creation,'; + $sql.= 'date_modification'; + + + $sql .= ') VALUES ('; + + $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; + $sql .= ' '.(! isset($this->shortname)?'NULL':"'".$this->db->escape($this->shortname)."'").','; + $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; + $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; + $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; + $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'"); + + + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_CREATE',$user); + //if ($result < 0) $error++; + //// End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.entity,"; + $sql .= " t.shortname,"; + $sql .= " t.description,"; + $sql .= " t.status,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_modification,"; + $sql .= " t.tms"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + if (null !== $ref) { + $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + } else { + $sql .= ' WHERE t.rowid = ' . $id; + } + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->entity = $obj->entity; + $this->shortname = $obj->shortname; + $this->description = $obj->description; + $this->status = $obj->status; + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_modification = $this->db->jdate($obj->date_modification); + $this->tms = $this->db->jdate($obj->tms); + + + } + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.entity,"; + $sql .= " t.shortname,"; + $sql .= " t.description,"; + $sql .= " t.status,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_modification,"; + $sql .= " t.tms"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield,$sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + } + $this->lines = array(); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $line = new WebsiteLine(); + + $line->id = $obj->rowid; + + $line->entity = $obj->entity; + $line->shortname = $obj->shortname; + $line->description = $obj->description; + $line->status = $obj->status; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_modification = $this->db->jdate($obj->date_modification); + $line->tms = $this->db->jdate($obj->tms); + + + + $this->lines[] = $line; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + // Clean parameters + + if (isset($this->entity)) { + $this->entity = trim($this->entity); + } + if (isset($this->shortname)) { + $this->shortname = trim($this->shortname); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->status)) { + $this->status = trim($this->status); + } + + + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + + $sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").','; + $sql .= ' shortname = '.(isset($this->shortname)?"'".$this->db->escape($this->shortname)."'":"null").','; + $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; + $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; + $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; + $sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').','; + $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); + + + $sql .= ' WHERE rowid=' . $this->id; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error && !$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + $this->db->begin(); + + if (!$error) { + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_DELETE',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + } + + if (!$error) { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; + $sql .= ' WHERE rowid=' . $this->id; + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * + * @return int New id of clone + */ + public function createFromClone($fromid) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + global $user; + $error = 0; + $object = new Website($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $result = $object->create($user); + + // Other options + if ($result < 0) { + $error ++; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + + return $object->id; + } else { + $this->db->rollback(); + + return - 1; + } + } + + /** + * Return a link to the user card (with optionaly the picto) + * Use this->id,this->lastname, this->firstname + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to + * @param integer $notooltip 1=Disable tooltip + * @param int $maxlen Max length of visible user name + * @param string $morecss Add more css on link + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') + { + global $langs, $conf, $db; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("MyModule") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $link = 'ref . $linkend; + return $result; + } + + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Renvoi le libelle d'un status donne + * + * @param int $status Id status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function LibStatut($status,$mode=0) + { + global $langs; + + if ($mode == 0) + { + $prefix=''; + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 1) + { + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 2) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 3) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + } + if ($mode == 4) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 5) + { + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + } + } + + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->entity = ''; + $this->shortname = ''; + $this->description = ''; + $this->status = ''; + $this->date_creation = ''; + $this->date_modification = ''; + $this->tms = ''; + + + } + +} + +/** + * Class WebsiteLine + */ +class WebsiteLine +{ + /** + * @var int ID + */ + public $id; + /** + * @var mixed Sample line property 1 + */ + + public $entity; + public $shortname; + public $description; + public $status; + public $date_creation = ''; + public $date_modification = ''; + public $tms = ''; + + /** + * @var mixed Sample line property 2 + */ + +} diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 7c52b440f44..a975bac297a 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -21,8 +21,49 @@ * \brief Page to setup the module Website */ + +/** + * Show HTML header HTML + BODY + Top menu + left menu + DIV + * + * @param string $head Optionnal head lines + * @param string $title HTML title + * @param string $help_url Url links to help page + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage + * For other external page: http://server/url + * @param string $target Target to use on links + * @param int $disablejs More content into html header + * @param int $disablehead More content into html header + * @param array $arrayofjs Array of complementary js files + * @param array $arrayofcss Array of complementary css files + * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) + * @return void + */ +function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') +{ + global $conf; + + // html header + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + + // top menu and left menu area + if (empty($conf->dol_hide_topmenu)) + { + top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); + } + if (empty($conf->dol_hide_leftmenu)) + { + left_menu('', $help_url, '', '', 1, $title, 1); + } + + // main area + //main_area($title); +} + + + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; $langs->load("admin"); $langs->load("other"); @@ -36,7 +77,7 @@ $conf->dol_hide_leftmenu = 1; $website='website1'; - +$object=new Website($db); /* @@ -75,12 +116,21 @@ $form = new Form($db); $help_url=''; -llxHeader('',$langs->trans("WebsiteSetup"),$help_url); +llxHeader('', $langs->trans("WebsiteSetup"), $help_url); +$style=' style="padding-top: 4px; padding-left: 10px; border-bottom: 1px solid #888; height: 20px; vertical-align: middle; margin-bottom: 5px;"'; -$linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("WebsiteSetup"),$linkback,'title_setup'); +print '
'; +// Loop on each sites + +$tmp = $object->fetchAll(); +foreach($object->lines as $websitearray) +{ + var_dump($websitearray); +} + +print '
'; $head = array(); @@ -95,10 +145,6 @@ if ($_SESSION['website_mode'] == 'edit') print ''; print ''; - dol_fiche_head($head, 'general', $langs->trans("Page").': '.$langs->trans("Home"), 0, 'globe'); - - print load_fiche_titre($langs->trans("SEO"),'',''); - print ''; print ''; print ''; @@ -152,8 +198,6 @@ if ($_SESSION['website_mode'] == 'edit') $doleditor=new DolEditor('WEBSITE_FOOTER',$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); $doleditor->Create(); - dol_fiche_end(); - print '
'; print ''; From e1d35c279787e21930270206ac33a8f082edb4f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 19:29:32 +0200 Subject: [PATCH 46/78] Fix waarnings --- htdocs/imports/class/import.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index fb842ef56ca..254628b38fa 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -33,13 +33,18 @@ class Import var $array_import_code; var $array_import_label; var $array_import_tables; + var $array_import_tables_creator; var $array_import_fields; + var $array_import_fieldshidden; var $array_import_entities; var $array_import_regex; var $array_import_examplevalues; var $array_import_convertvalue; var $array_import_run_sql_after; + var $error; + var $errors; + /** * Constructor @@ -138,7 +143,7 @@ class Import $this->array_import_label[$i]=$module->getImportDatasetLabel($r); // Array of tables to import (key=alias, value=tablename) $this->array_import_tables[$i]=$module->import_tables_array[$r]; - // Array of tables creator field to import (key=alias, value=creator field) + // Array of tables creator field to import (key=alias, value=creator field name) $this->array_import_tables_creator[$i]=(isset($module->import_tables_creator_array[$r])?$module->import_tables_creator_array[$r]:''); // Array of fields to import (key=field, value=label) $this->array_import_fields[$i]=$module->import_fields_array[$r]; From 9de6d31c87d21642b5ce5a5167d5979cf9499dd5 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 13 Apr 2016 15:57:46 +0200 Subject: [PATCH 47/78] New add link to widthdraw slip card on bank transaction --- htdocs/compta/paiement/class/paiement.class.php | 12 ++++++++++++ .../prelevement/class/bonprelevement.class.php | 1 + 2 files changed, 13 insertions(+) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index daf43ec9d64..9e81180c4fe 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -563,6 +563,18 @@ class Paiement extends CommonObject } } + // Add link 'WithdrawalPayment' in bank_url + if (! $error && $label == '(WithdrawalPayment)') + { + $result=$acc->add_url_line( + $bank_line_id, + $this->id_prelevement, + DOL_URL_ROOT.'/compta/prelevement/card.php?id=', + $this->num_paiement, + 'withdraw' + ); + } + if (! $error && ! $notrigger) { // Appel des triggers diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3c3a7d14ca0..31d9e4d67c1 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -462,6 +462,7 @@ class BonPrelevement extends CommonObject $paiement->amounts = $amounts; $paiement->paiementid = 3; // $paiement->num_paiement = $this->ref ; + $paiement->id_prelevement = $this->id ; $paiement_id = $paiement->create($user); if ($paiement_id < 0) From 1676595b93b0a0edeeb5314abdf2a70d7ce605e9 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 14 Apr 2016 10:50:32 +0200 Subject: [PATCH 48/78] NEW: fichinter lines ordered by rang AND DATE --- htdocs/fichinter/card.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index a247341cdec..7a54d4237f3 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1409,7 +1409,7 @@ else if ($id > 0 || ! empty($ref)) $sql.= ' WHERE ft.fk_fichinter = '.$object->id; if (!empty($conf->global->FICHINTER_HIDE_EMPTY_DURATION)) $sql.= ' AND ft.duree <> 0'; - $sql.= ' ORDER BY ft.rang ASC, ft.rowid'; + $sql.= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid'; $resql = $db->query($sql); if ($resql) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index c1e7a3aaca2..11b8629bc3a 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -969,7 +969,7 @@ class Fichinter extends CommonObject { $sql = 'SELECT rowid, description, duree, date, rang'; $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet'; - $sql.=' WHERE fk_fichinter = '.$this->id .' ORDER BY rang ASC' ; + $sql.=' WHERE fk_fichinter = '.$this->id .' ORDER BY rang ASC, date ASC' ; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql=$this->db->query($sql); From b5f7f962cc835d39c8e0faeeaf3b6311b452f581 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 15 Apr 2016 16:05:47 +0200 Subject: [PATCH 49/78] FIX Travis fails --- htdocs/core/modules/import/import_csv.modules.php | 3 ++- htdocs/core/modules/import/import_xlsx.modules.php | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 245f1a15794..895ed6de89d 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -171,6 +171,7 @@ class ImportCsv extends ModeleImports /** * Return nb of records. File must be closed. * + * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ function import_get_nb_of_lines($file) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 309e3dd7085..627fcfd6fd9 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -214,7 +214,8 @@ class Importxlsx extends ModeleImports /** * Return nb of records. File must be closed. - * + * + * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ function import_get_nb_of_lines($file) From f86952dfaa5fef098a89332f23c9d44f1dcd1e15 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 15 Apr 2016 16:57:11 +0200 Subject: [PATCH 50/78] FIX Add missing field fk_shipping_method_id --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 1 + htdocs/install/mysql/tables/llx_societe.sql | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 8296aa82e74..70cb245c772 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -382,3 +382,4 @@ ALTER TABLE llx_product_fournisseur_price ADD supplier_reputation varchar(10) NU -- Delete old deprecated field ALTER TABLE llx_product_stock DROP COLUMN pmp; +ALTER TABLE llx_societe ADD COLUMN fk_shipping_method_id integer; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 9822272e7c2..e5d6f722d2c 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -103,5 +103,6 @@ create table llx_societe webservices_key varchar(128), -- supplier webservice key fk_multicurrency integer, - multicurrency_code varchar(255) + multicurrency_code varchar(255), + fk_shipping_method_id integer )ENGINE=innodb; From bc949cafd28ef6c216720d345eb0fc5ef2bdfc3b Mon Sep 17 00:00:00 2001 From: appchecker Date: Sat, 16 Apr 2016 13:39:55 +0300 Subject: [PATCH 51/78] fix: comparing instead of assign --- htdocs/theme/md/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8997231230f..30188232239 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -120,7 +120,7 @@ if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) $conf->global->THEME_ELDY_LINEPAIR1='250,250,250'; $conf->global->THEME_ELDY_LINEPAIR2='248,248,248'; $conf->global->THEME_ELDY_LINEPAIRHOVER='238,246,252'; - $conf->global->THEME_ELDY_USE_HOVER=='238,246,252'; + $conf->global->THEME_ELDY_USE_HOVER='238,246,252'; $conf->global->THEME_ELDY_TEXT='0,0,0'; $conf->global->THEME_ELDY_FONT_SIZE1='13'; $conf->global->THEME_ELDY_FONT_SIZE2='11'; From 3722fc1014245c2e5622d909fbd5bd1a44228a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 16 Apr 2016 20:16:38 +0200 Subject: [PATCH 52/78] Refactored FormVentilation class --- .../class/html.formventilation.class.php | 344 +++++++----------- 1 file changed, 122 insertions(+), 222 deletions(-) diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index b0b58a7a921..e17e4406376 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2015 Ari Elbaz (elarifr) + * Copyright (C) 2016 Marcos García * * 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 @@ -29,18 +30,6 @@ */ class FormVentilation extends Form { - var $db; - var $error; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) { - $this->db = $db; - } - /** * Return select filter with date of transaction * @@ -49,38 +38,25 @@ class FormVentilation extends Form * @return string HTML edit field */ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') { + $options = array(); + $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; $sql .= ' ORDER BY import_key DESC'; - - $out = ''; - - return $out; + + while ($obj = $this->db->fetch_object($resql)) { + $options[$obj->import_key] = dol_print_date($obj->import_key, 'dayhourtext'); + } + + return Form::selectarray($htmlname, $options, $selectedkey); } /** @@ -100,8 +76,8 @@ class FormVentilation extends Form global $conf; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; - - $out = ''; + + $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; @@ -110,49 +86,44 @@ class FormVentilation extends Form $sql .= " AND aa.active = 1"; $sql .= " ORDER BY aa.account_number"; - dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) { - - $out .= ajax_combobox($htmlname, $event); - $out .= ''; - } else { + + if (!$resql) { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); - return - 1; + return -1; } + + $out = ajax_combobox($htmlname, $event); + + $options = array(); + $selected = null; + + while ($obj = $this->db->fetch_object($resql)) { + $label = length_accountg($obj->account_number) . ' - ' . $obj->label; + $label = dol_trunc($label, $trunclength); + + $select_value_in = $obj->rowid; + $select_value_out = $obj->rowid; + + if ($select_in == 1) { + $select_value_in = $obj->account_number; + } + if ($select_out == 1) { + $select_value_out = $obj->account_number; + } + + // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number + // Because same account_number can be share between different accounting_system and do have the same meaning + if (($selectid != '') && $selectid == $select_value_in) { + $selected = $select_value_out; + } + + $options[$select_value_out] = $label; + } + + $out .= Form::selectarray($htmlname, $options, $selected, $showempty); $this->db->free($resql); return $out; } @@ -170,44 +141,30 @@ class FormVentilation extends Form function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) { global $conf; - $out = ''; - $sql = "SELECT DISTINCT pcg_type "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " ORDER BY pcg_type"; - dol_syslog(get_class($this) . "::select_pcgtype sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_pcgtype", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) { - - $out .= ajax_combobox($htmlname, $event); - - $out .= ''; - } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_pcgtype " . $this->error, LOG_ERR); - return - 1; + + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_pcgtype ".$this->error, LOG_ERR); + return -1; } + + $options = array(); + $out = ajax_combobox($htmlname, $event); + + while ($obj = $this->db->fetch_object($resql)) { + $options[$obj->pcg_type] = $obj->pcg_type; + } + + $out .= Form::selectarray($htmlname, $options, $selectid, $showempty); + $this->db->free($resql); return $out; } @@ -225,44 +182,30 @@ class FormVentilation extends Form function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) { global $conf; - $out = ''; - $sql = "SELECT DISTINCT pcg_subtype "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " ORDER BY pcg_subtype"; - dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_pcgsubtype", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) { - - $out .= ajax_combobox($htmlname, $event); - - $out .= ''; - } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_pcgsubtype " . $this->error, LOG_ERR); - return - 1; + + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR); + return -1; } + + $options = array(); + $out = ajax_combobox($htmlname, $event); + + while ($obj = $this->db->fetch_object($resql)) { + $options[$obj->pcg_subtype] = $obj->pcg_subtype; + } + + $out .= Form::selectarray($htmlname, $options, $selectid, $showempty); + $this->db->free($resql); return $out; } @@ -278,68 +221,51 @@ class FormVentilation extends Form * @return string String with HTML select */ function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) { - global $conf; - - $out = ''; - - $aux_account = array (); - + + $aux_account = array(); + // Auxiliary customer account $sql = "SELECT DISTINCT code_compta, nom "; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; $sql .= " ORDER BY code_compta"; - dol_syslog(get_class($this) . "::select_auxaccount", LOG_DEBUG); + dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - while ( $obj = $this->db->fetch_object($resql) ) { - if (! empty($obj->code_compta)) { - $aux_account[$obj->code_compta] = $obj->code_compta . ' (' . $obj->nom . ')'; + while ($obj = $this->db->fetch_object($resql)) { + if (!empty($obj->code_compta)) { + $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')'; } } } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_pcgsubtype " . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR); + return -1; } $this->db->free($resql); - + // Auxiliary supplier account $sql = "SELECT DISTINCT code_compta_fournisseur, nom "; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; $sql .= " ORDER BY code_compta"; - dol_syslog(get_class($this) . "::select_auxaccount", LOG_DEBUG); + dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - while ( $obj = $this->db->fetch_object($resql) ) { - if (! empty($obj->code_compta_fournisseur)) { - $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur . ' (' . $obj->nom . ')'; + while ($obj = $this->db->fetch_object($resql)) { + if (!empty($obj->code_compta_fournisseur)) { + $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')'; } } } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_pcgsubtype " . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR); + return -1; } $this->db->free($resql); - + // Build select - if (count($aux_account) > 0) { - - $out .= ajax_combobox($htmlname, $event); - - $out .= ''; - } - + $out = ajax_combobox($htmlname, $event); + $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty); + return $out; } @@ -352,55 +278,29 @@ class FormVentilation extends Form * @param string $output_format (html/opton (for option html only)/array (to return options arrays * @return string/array */ - function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html') { - $out = ''; - $out_array = array (); - - if ($output_format == 'html') { - $out .= '\n"; - } - - if ($output_format == 'html' || $output_format == 'options') { - return $out; - } elseif ($output_format == 'array') { + return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"'); + } else { return $out_array; } } From 863efcbc5d4b96d1212ca3babee9f379d15ad1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 16 Apr 2016 21:33:23 +0200 Subject: [PATCH 53/78] NEW Removed unused FormOrder::selectSourcesCommande function Also refactored select functions to avoid using HTML and encourage using Form::selectarray function --- htdocs/core/class/dolreceiptprinter.class.php | 44 +++---- htdocs/core/class/html.formcompany.class.php | 33 +++--- htdocs/core/class/html.formmailing.class.php | 34 +----- htdocs/core/class/html.formorder.class.php | 111 ++++++------------ htdocs/margin/admin/margin.php | 21 ++-- htdocs/product/document.php | 36 +----- .../canvas/actions_card_common.class.php | 12 +- 7 files changed, 91 insertions(+), 200 deletions(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 90bf948e215..2499176b58b 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -300,17 +300,17 @@ class dolReceiptPrinter extends Escpos function selectTypePrinter($selected='', $htmlname='printertypeid') { global $langs; - $error = 0; - $html = ''; - - $this->resprint = $html; - return $error; + + $options = array( + 1 => $langs->trans('CONNECTOR_DUMMY'), + 2 => $langs->trans('CONNECTOR_FILE_PRINT'), + 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), + 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT') + ); + + $this->resprint = Form::selectarray($htmlname, $options, $selected); + + return 0; } @@ -324,17 +324,17 @@ class dolReceiptPrinter extends Escpos function selectProfilePrinter($selected='', $htmlname='printerprofileid') { global $langs; - $error = 0; - $html = ''; - - $this->profileresprint = $html; - return $error; + + $options = array( + 0 => $langs->trans('PROFILE_DEFAULT'), + 1 => $langs->trans('PROFILE_SIMPLE'), + 2 => $langs->trans('PROFILE_EPOSTEP'), + 3 => $langs->trans('PROFILE_P822D'), + 4 => $langs->trans('PROFILE_STAR') + ); + + $this->profileresprint = Form::selectarray($htmlname, $options, $selected); + return 0; } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 9091b4aead0..d51765e2a16 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -146,9 +146,6 @@ class FormCompany print '
'.$langs->trans("Description").'
'; print ''; print ''; diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 3c47aceee8a..0c63049f9d8 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -27,22 +27,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; */ class FormMailing extends Form { - public $db; - public $error; public $errors=array(); - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - return 1; - } - /** * Output a select with destinaries status * @@ -59,26 +45,14 @@ class FormMailing extends Form require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; $mailing = new Mailing($this->db); - - $array = $mailing->statut_dest; - //Cannot use form->selectarray because empty value is defaulted to -1 in this method and we use here status -1... - - $out = ''; - return $out; + return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1); } } diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index 4ecbef60b58..68fa96e03ee 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2016 Marcos García * * 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 @@ -21,29 +22,14 @@ * \brief File of predefined functions for HTML forms for order module */ +require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; /** * Class to manage HTML output components for orders * Before adding component here, check they are not into common part Form.class.php */ -class FormOrder +class FormOrder extends Form { - var $db; - var $error; - - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - return 1; - } - /** * Return combo list of differents status of a orders @@ -53,51 +39,32 @@ class FormOrder * @param string $hmlname Name of HTML select element * @return void */ - function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') + public function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') { - $tmpsupplierorder=new CommandeFournisseur($db); - - print ''; + // 7 is same label than 6. 8 does not exists (billed is another field) + $statustohow = array( + '0' => '0', + '1' => '1', + '2' => '2', + '3' => '3', + '4' => '4', + '5' => '5', + '6' => '6,7', + '9' => '9' + ); + + $tmpsupplierorder = new CommandeFournisseur($this->db); + + foreach ($statustohow as $key => $value) { + $tmpsupplierorder->statut = $key; + $options[$value] = $tmpsupplierorder->getLibStatut($short); + } + + print Form::selectarray($hmlname, $options, $selected, 1); } - /** - * Return list of way to order - * - * @param string $selected Id of preselected order origin - * @param string $htmlname Name of HTML select list - * @param int $addempty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * @return array Tableau des sources de commandes - */ - function selectSourcesCommande($selected='',$htmlname='source_id',$addempty=0) - { - global $conf,$langs; - print ''; - } - - /** * Return list of input method (mode used to receive order, like order received by email, fax, online) * List found into table c_input_method. @@ -107,11 +74,9 @@ class FormOrder * @param int $addempty 0=list with no empty value, 1=list with empty value * @return array Tableau des sources de commandes */ - function selectInputMethod($selected='',$htmlname='source_id',$addempty=0) + public function selectInputMethod($selected='',$htmlname='source_id',$addempty=0) { - global $conf,$langs,$form; - - if (! is_object($form)) $form=new Form($this->db); + global $langs; $listofmethods=array(); @@ -121,24 +86,18 @@ class FormOrder dol_syslog(get_class($this)."::selectInputMethod", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { - $i = 0; - $num = $this->db->num_rows($resql); - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $listofmethods[$obj->rowid] = $langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):$obj->label; - $i++; - } - } - else - { + + if (!$resql) { dol_print_error($this->db); return -1; } - print $form->selectarray($htmlname,$listofmethods,$selected,$addempty); + while ($obj = $this->db->fetch_object($resql)) { + $listofmethods[$obj->rowid] = $langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : $obj->label; + } + + print Form::selectarray($htmlname,$listofmethods,$selected,$addempty); + return 1; } diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index 6e84b13e286..3a61ee0e72e 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -236,6 +236,12 @@ print ''; print ''; // GLOBAL DISCOUNT MANAGEMENT +$methods = array( + 1 => $langs->trans('UseDiscountAsProduct'), + 2 => $langs->trans('UseDiscountAsService'), + 3 => $langs->trans('UseDiscountOnTotal') +); + $var=!$var; print ''; print ''; @@ -243,20 +249,7 @@ print ""; print ''; print ''; print ''; print '"; - print ''; + print ''; // Delivery address if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 1e5ace7353e..91972673201 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -99,10 +99,10 @@ if ($id > 0 || ! empty($ref)) print ''; // Customer - if ( is_null($object->client) ) + if ( is_null($object->thirdparty) ) $object->fetch_thirdparty(); print ""; - print ''; + print ''; // Discounts print ''; // Customer - if (is_null($object->client)) $object->fetch_thirdparty(); + if (is_null($object->thirdparty)) $object->fetch_thirdparty(); print ""; - print ''; + print ''; // Delivery address if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4d216a80264..d89871674b7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1932,7 +1932,7 @@ class Facture extends CommonInvoice $this->date=dol_now(); $this->date_lim_reglement=$this->calculate_date_lim_reglement(); } - $num = $this->getNextNumRef($this->client); + $num = $this->getNextNumRef($this->thirdparty); } else { @@ -1971,7 +1971,7 @@ class Facture extends CommonInvoice if (! $error) { // Define third party as a customer - $result=$this->client->set_as_client(); + $result=$this->thirdparty->set_as_client(); // Si active on decremente le produit principal et ses composants a la validation de facture if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) @@ -3085,7 +3085,7 @@ class Facture extends CommonInvoice // If not a draft invoice and not temporary invoice if ($facref != 'PROV') { - $maxfacnumber = $this->getNextNumRef($this->client,'last'); + $maxfacnumber = $this->getNextNumRef($this->thirdparty,'last'); $ventilExportCompta = $this->getVentilExportCompta(); // If there is no invoice into the reset range and not already dispatched, we can delete if ($maxfacnumber == '' && $ventilExportCompta == 0) return 1; diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index b07a8f8c2d4..c5a7cfcdab2 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -175,7 +175,7 @@ if ($id > 0 || ! empty($ref)) // Customer print ""; - print ''; + print ''; print "
'; - print ''; print ''.$langs->trans('ForceBuyingPriceIfNullDetails').'
'.$langs->trans("MARGIN_METHODE_FOR_DISCOUNT").''; -print ''; +print Form::selectarray('MARGIN_METHODE_FOR_DISCOUNT', $methods, $conf->global->MARGIN_METHODE_FOR_DISCOUNT); print ''; print ''; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index facff9f9a52..ca207f8429f 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -262,43 +262,11 @@ if ($object->id) print '
'; - $delauft_lang = (empty($lang_id)) ? $langs->getDefaultLang() : $lang_id; + $delauft_lang = empty($lang_id) ? $langs->getDefaultLang() : $lang_id; $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); - print ''; + print Form::selectarray('lang_id', $langs_available, $delauft_lang, 0, 0, 0, '', 0, 0, 0, 'ASC'); if ($conf->global->MAIN_MULTILANGS) { print ''; diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 782a7f070c4..74a05cba39d 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -439,12 +439,12 @@ abstract class ActionsCardCommon if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed(); // TODO create a function - $this->tpl['select_customertype'] = ''; + $this->tpl['select_customertype'] = Form::selectarray('client', array( + 0 => $langs->trans('NorProspectNorCustomer'), + 1 => $langs->trans('Customer'), + 2 => $langs->trans('Prospect'), + 3 => $langs->trans('ProspectCustomer') + ), $this->object->client); // Customer $this->tpl['customercode'] = $this->object->code_client; From 84b58d27e680d3f59eb53ef44dec27678dcb3cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 16 Apr 2016 21:41:06 +0200 Subject: [PATCH 54/78] NEW Renamed ActionComm::add function to ActionComm::create --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 20 ++++++++++++++++--- ...terface_50_modAgenda_ActionsAuto.class.php | 2 +- htdocs/webservices/server_actioncomm.php | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 62798371a58..4ca75ade9b9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -318,7 +318,7 @@ if ($action == 'add') $db->begin(); // On cree l'action - $idaction=$object->add($user); + $idaction=$object->create($user); if ($idaction > 0) { diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index d4e56bb2715..c0e1f11579c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -173,7 +173,7 @@ class ActionComm extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; @@ -189,7 +189,7 @@ class ActionComm extends CommonObject * @param int $notrigger 1 = disable triggers, 0 = enable triggers * @return int Id of created event, < 0 if KO */ - function add($user,$notrigger=0) + public function create(User $user, $notrigger = 0) { global $langs,$conf,$hookmanager; @@ -395,6 +395,20 @@ class ActionComm extends CommonObject } + /** + * Add an action/event into database. + * $this->type_id OR $this->type_code must be set. + * + * @param User $user Object user making action + * @param int $notrigger 1 = disable triggers, 0 = enable triggers + * @return int Id of created event, < 0 if KO + * @deprecated Use create instead + */ + public function add(User $user, $notrigger = 0) + { + $this->create($user, $notrigger); + } + /** * Load an object from its id and create a new one in database * @@ -436,7 +450,7 @@ class ActionComm extends CommonObject } // Create clone - $result=$this->add($fuser); + $result=$this->create($fuser); if ($result < 0) $error++; if (! $error) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 0a5d4a81ed6..5c85309ed8c 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -803,7 +803,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->fk_element = $object->id; $actioncomm->elementtype = $object->element; - $ret=$actioncomm->add($user); // User creating action + $ret=$actioncomm->create($user); // User creating action unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index dc07bc156ec..a5df31c2a7e 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -459,7 +459,7 @@ function createActionComm($authentication,$actioncomm) $db->begin(); - $result=$newobject->add($fuser); + $result=$newobject->create($fuser); if ($result <= 0) { $error++; From 21ba24a0cdfd3452f21dac5026e0f6e8585e5d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 16 Apr 2016 22:13:28 +0200 Subject: [PATCH 55/78] NEW Deprecated Societe::set_prospect_level, Societe::set_commnucation_level, Societe::set_OutstandingBill functions --- htdocs/comm/card.php | 6 +- htdocs/societe/class/societe.class.php | 80 ++++---------------------- htdocs/societe/list.php | 2 +- 3 files changed, 14 insertions(+), 74 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 62b251ac01d..a5c4d4980e8 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -146,7 +146,7 @@ if (empty($reshook)) { $object->fetch($id); $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); - $result=$object->set_prospect_level($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -155,7 +155,7 @@ if (empty($reshook)) { $object->fetch($id); $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); - $result=$object->set_commnucation_level($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -164,7 +164,7 @@ if (empty($reshook)) { $object->fetch($id); $object->outstanding_limit=GETPOST('outstanding_limit'); - $result=$object->set_OutstandingBill($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1005b8c3c8d..60e954c9f6e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -678,6 +678,7 @@ class Societe extends CommonObject $this->idprof5 = (! empty($this->idprof5)?trim($this->idprof5):''); $this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):''); $this->prefix_comm = trim($this->prefix_comm); + $this->outstanding_limit = price2num($this->outstanding_limit); $this->tva_assuj = trim($this->tva_assuj); $this->tva_intra = dol_sanitizeFileName($this->tva_intra,''); @@ -831,7 +832,7 @@ class Societe extends CommonObject $sql .= ",prefix_comm = ".(! empty($this->prefix_comm)?"'".$this->db->escape($this->prefix_comm)."'":"null"); $sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->db->escape($this->effectif_id)."'":"null"); - + $sql .= ",fk_stcomm='".$this->stcomm_id."'"; $sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->db->escape($this->typent_id)."'":"0"); $sql .= ",fk_forme_juridique = ".(! empty($this->forme_juridique_code)?"'".$this->db->escape($this->forme_juridique_code)."'":"null"); @@ -847,6 +848,8 @@ class Societe extends CommonObject $sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->db->escape($this->barcode)."'":"null"); $sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null"); $sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null"); + $sql .= ",outstanding_limit= '".($this->outstanding_limit!=''?$this->outstanding_limit:'null')."'"; + $sql .= ",fk_prospectlevel='".$this->fk_prospectlevel."'"; $sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null"); $sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null"); @@ -3178,30 +3181,11 @@ class Societe extends CommonObject * * @param User $user Utilisateur qui definie la remise * @return int <0 if KO, >0 if OK + * @deprecated Use update function instead */ function set_prospect_level(User $user) { - if ($this->id) - { - $this->db->begin(); - - // Positionne remise courante - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " fk_prospectlevel='".$this->fk_prospectlevel."'"; - $sql.= ",fk_user_modif='".$user->id."'"; - $sql.= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::set_prospect_level", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $this->db->rollback(); - $this->error=$this->db->error(); - return -1; - } - - $this->db->commit(); - return 1; - } + return $this->update($this->id, $user); } /** @@ -3274,31 +3258,11 @@ class Societe extends CommonObject * * @param User $user User making change * @return int <0 if KO, >0 if OK + * @deprecated Use update function instead */ function set_commnucation_level($user) { - if ($this->id) - { - $this->db->begin(); - - // Positionne remise courante - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " fk_stcomm='".$this->stcomm_id."'"; - $sql.= ",fk_user_modif='".$user->id."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::set_commnucation_level", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } - - $this->db->commit(); - return 1; - } + return $this->update($this->id, $user); } /** @@ -3306,35 +3270,11 @@ class Societe extends CommonObject * * @param User $user User making change * @return int <0 if KO, >0 if OK + * @deprecated Use update function instead */ function set_OutstandingBill(User $user) { - if ($this->id) - { - $this->db->begin(); - - // Clean parameters - $outstanding = price2num($this->outstanding_limit); - - // Set outstanding amount - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " outstanding_limit= '".($outstanding!=''?$outstanding:'null')."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::set_outstanding", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } - } + return $this->update($this->id, $user); } /** diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e01331617ea..4e9d0b1ed18 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -191,7 +191,7 @@ if (empty($reshook)) $object = new Client($db); $result=$object->fetch(GETPOST('stcommsocid')); $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); - $result=$object->set_commnucation_level($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); $action=''; From d5980a5bf8039a4f86a400387841488d03abf5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 17 Apr 2016 12:20:45 +0200 Subject: [PATCH 56/78] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 46b485d8a3c..23b0fc5d6e2 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -920,6 +920,7 @@ class FormMail extends Form */ function setSubstitFromObject($object) { + global $user; $this->substit['__REF__'] = $object->ref; $this->substit['__SIGNATURE__'] = $user->signature; $this->substit['__REFCLIENT__'] = $object->ref_client; From 54dd1763fe56fba7f4f9360a167430e2ef704a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 17 Apr 2016 15:05:54 +0200 Subject: [PATCH 57/78] Little refactor --- htdocs/core/lib/company.lib.php | 20 ++++++++++---------- htdocs/core/lib/functions.lib.php | 7 ++----- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e2d63d6d151..8631c576576 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -57,17 +57,17 @@ function societe_prepare_head(Societe $object) if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client==1 || $object->client==3)) $head[$h][1] .= $langs->trans("Customer"); $head[$h][2] = 'customer'; $h++; - } - if (($object->client==1 || $object->client==2 || $object->client==3) && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))) - { - $langs->load("products"); - // price - $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id; - $head[$h][1] = $langs->trans("CustomerPrices"); - $head[$h][2] = 'price'; - $h++; - } + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + $langs->load("products"); + // price + $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id; + $head[$h][1] = $langs->trans("CustomerPrices"); + $head[$h][2] = 'price'; + $h++; + } + } if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) { $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6b69427eacd..befcf4ef4ff 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3929,13 +3929,10 @@ function get_product_localtax_for_country($idprod, $local, $thirdparty_seller) * @return float Taux de tva a appliquer, -1 si ne peut etre determine * @see get_default_npr, get_default_localtax */ -function get_default_tva($thirdparty_seller, $thirdparty_buyer, $idprod=0, $idprodfournprice=0) +function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0) { global $conf; - if (!is_object($thirdparty_seller)) return -1; - if (!is_object($thirdparty_buyer)) return -1; - // Note: possible values for tva_assuj are 0/1 or franchise/reel $seller_use_vat=((is_numeric($thirdparty_seller->tva_assuj) && ! $thirdparty_seller->tva_assuj) || (! is_numeric($thirdparty_seller->tva_assuj) && $thirdparty_seller->tva_assuj=='franchise'))?0:1; @@ -4012,7 +4009,7 @@ function get_default_tva($thirdparty_seller, $thirdparty_buyer, $idprod=0, $idpr * @return float 0 or 1 * @see get_default_tva, get_default_localtax */ -function get_default_npr($thirdparty_seller, $thirdparty_buyer, $idprod=0, $idprodfournprice=0) +function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0) { global $db; From e2c86d3fd856644adb0e12aec226a3ea1bc54a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 17 Apr 2016 15:24:22 +0200 Subject: [PATCH 58/78] NEW Removed deprecated CommonObject::client property. Please use CommonObject::thirdparty instead --- htdocs/comm/propal/class/propal.class.php | 14 +++++------ htdocs/comm/propal/contact.php | 2 +- htdocs/comm/propal/note.php | 4 ++-- htdocs/commande/class/commande.class.php | 12 +++++----- htdocs/commande/contact.php | 4 ++-- htdocs/compta/facture/class/facture.class.php | 6 ++--- htdocs/compta/facture/contact.php | 2 +- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/compta/paiement.php | 4 ++-- htdocs/core/class/commonobject.class.php | 8 ------- htdocs/core/lib/files.lib.php | 2 +- .../doc/doc_generic_order_odt.modules.php | 4 ++-- .../contract/doc/pdf_strato.modules.php | 12 +++++----- .../doc/doc_generic_shipment_odt.modules.php | 4 ++-- .../doc/doc_generic_invoice_odt.modules.php | 4 ++-- .../pdf/pdf_canelle.modules.php | 2 +- .../pdf/pdf_muscadet.modules.php | 6 ++--- ..._generic_supplier_proposal_odt.modules.php | 4 ++-- htdocs/don/card.php | 2 +- htdocs/expedition/card.php | 6 ++--- htdocs/expedition/shipment.php | 2 +- htdocs/fichinter/card.php | 24 +++++++++---------- htdocs/fichinter/contact.php | 4 ++-- htdocs/fichinter/document.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/commande/card.php | 6 ++--- htdocs/fourn/facture/card.php | 8 +++---- htdocs/livraison/card.php | 6 ++--- htdocs/product/card.php | 2 +- .../class/supplier_proposal.class.php | 16 ++++++------- htdocs/supplier_proposal/note.php | 4 ++-- 32 files changed, 87 insertions(+), 95 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a83600072d4..99f5058ad3f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -247,16 +247,16 @@ class Propal extends CommonObject $productdesc = $prod->description; - $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); - $tva_npr = get_default_npr($mysoc,$this->client,$prod->id); + $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); + $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->client,$tva_npr); - $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->client,$tva_npr); + $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->thirdparty,$tva_npr); + $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->thirdparty,$tva_npr); // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) + if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) { - $price = $prod->multiprices[$this->client->price_level]; + $price = $prod->multiprices[$this->thirdparty->price_level]; } else { @@ -1975,7 +1975,7 @@ class Propal extends CommonObject if (! empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); } //$ret=$object->fetch($id); // Reload to get new records diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 544c5ab27e3..33504a1d27b 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -177,7 +177,7 @@ if ($object->id > 0) // Customer print "
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
'.$langs->trans('Discounts').''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ae7c18ac077..827f3976fc8 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1420,15 +1420,15 @@ class Commande extends CommonOrder $prod=new Product($this->db); $prod->fetch($idproduct); - $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); - $tva_npr = get_default_npr($mysoc,$this->client,$prod->id); + $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); + $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx=get_localtax($tva_tx,1,$this->client,$mysoc,$tva_npr); - $localtax2_tx=get_localtax($tva_tx,2,$this->client,$mysoc,$tva_npr); + $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr); + $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr); // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) - $price = $prod->multiprices[$this->client->price_level]; + if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) + $price = $prod->multiprices[$this->thirdparty->price_level]; else $price = $prod->price; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 93d46c05997..da584f9197c 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -171,10 +171,10 @@ if ($id > 0 || ! empty($ref)) print '
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
".$langs->trans("Company")."'.$object->client->getNomUrl(1,'compta').'
'.$object->thirdparty->getNomUrl(1,'compta').'
"; dol_fiche_end(); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 9b381c1af04..275724d3012 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -281,7 +281,7 @@ if ($action == 'create') $object->fetch_thirdparty(); // Third party - print ''.$langs->trans("Customer").''.$object->client->getNomUrl(1,'customer').''; + print ''.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').''; print ''; print $langs->trans("Comment"); print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 64813c56f1d..e2883081452 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -540,7 +540,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 37b6ebdc3eb..fa1341dcbc6 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -449,14 +449,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; - print ''; + print ''; dol_fiche_head(); print ''; // Third party - print '\n"; + print '\n"; // Date payment print ''; // Third party - print ""; + print ""; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { @@ -1824,7 +1824,7 @@ else if ($id > 0 || ! empty($ref)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index b92c1442d14..b64a16f91ba 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -133,11 +133,11 @@ if ($id > 0 || ! empty($ref)) print ""; // Customer - if ( is_null($object->client) ) + if ( is_null($object->thirdparty) ) $object->fetch_thirdparty(); print ""; - print ''; + print ''; print "
'.$langs->trans('Company').''.$facture->client->getNomUrl(4)."
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
'.$langs->trans('Date').''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7de64135245..7cc889a67e9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -130,12 +130,6 @@ abstract class CommonObject * @see fetch_thirdparty() */ public $thirdparty; - /** - * @deprecated - * @var Societe A related customer - * @see thirdparty - */ - public $client; /** * @var User A related user @@ -1016,12 +1010,10 @@ abstract class CommonObject if ($idtofetch) { $thirdparty = new Societe($this->db); $result = $thirdparty->fetch($idtofetch); - $this->client = $thirdparty; // deprecated $this->thirdparty = $thirdparty; // Use first price level if level not defined for third party if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->thirdparty->price_level)) { - $this->client->price_level = 1; // deprecated $this->thirdparty->price_level = 1; } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 7d8ac5f1750..9be021b975e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1358,7 +1358,7 @@ function dol_meta_create($object) if (is_dir($dir)) { $nblignes = count($object->lines); - $client = $object->client->name . " " . $object->client->address . " " . $object->client->zip . " " . $object->client->town; + $client = $object->thirdparty->name . " " . $object->thirdparty->address . " " . $object->thirdparty->zip . " " . $object->thirdparty->town; $meta = "REFERENCE=\"" . $object->ref . "\" DATE=\"" . dol_print_date($object->date,'') . "\" NB_ITEMS=\"" . $nblignes . "\" diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 84dec7b817e..9e26b31b0ce 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -289,11 +289,11 @@ class doc_generic_order_odt extends ModelePDFCommandes { // 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->client; + else $socobject = $object->thirdparty; } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Make substitution diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 25ae8c7f015..f8097249a5b 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -556,12 +556,12 @@ class pdf_strato extends ModelePDFContract $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_creation,"day",false,$outputlangs,true), '', 'R'); - if ($object->client->code_client) + if ($object->thirdparty->code_client) { $posy+=4; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } if ($showaddress) @@ -576,7 +576,7 @@ class pdf_strato extends ModelePDFContract $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender $posy=42; @@ -614,19 +614,19 @@ class pdf_strato extends ModelePDFContract $result=$object->fetch_contact($arrayidcontact[0]); } - $this->recipient = $object->client; + $this->recipient = $object->thirdparty; //Recipient name // On peut utiliser le nom de la societe du contact if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { - $thirdparty = $object->client; + $thirdparty = $object->thirdparty; } $this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object); + $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object); // Show recipient $widthrecbox=100; diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index c2fcf108c10..2693a4f013a 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -289,11 +289,11 @@ class doc_generic_shipment_odt extends ModelePdfExpedition { // 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->client; + else $socobject = $object->thirdparty; } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Make substitution 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 2cd392a0bd6..a8baaab2282 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 @@ -291,14 +291,14 @@ class doc_generic_invoice_odt extends ModelePDFFactures // 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->client; + $socobject = $object->thirdparty; // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; } } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Fetch info for linked propal diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index ae96756b9f0..ddbea30e833 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -1061,7 +1061,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender $posy=42; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 2d30037878d..225ff02e629 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -1113,7 +1113,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender $posy=42; @@ -1158,12 +1158,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { - $thirdparty = $object->client; + $thirdparty = $object->thirdparty; } $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target',$object); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object); // Show recipient $widthrecbox=100; diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index d1386d646a5..212685ba519 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -320,11 +320,11 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal { // 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->client; + else $socobject = $object->thirdparty; } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Make substitution diff --git a/htdocs/don/card.php b/htdocs/don/card.php index cd8a2e174f8..fab2560f816 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -264,7 +264,7 @@ if ($action == 'builddoc') $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 8f461a2a0c0..4547a94566a 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -501,7 +501,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -1562,7 +1562,7 @@ else if ($id || $ref) $outputlangs = $langs; $newlang=''; if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); - if (empty($newlang)) $newlang=$object->client->default_lang; + if (empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -1850,7 +1850,7 @@ else if ($id || $ref) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 2677d06ec7b..5de764922e1 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -530,7 +530,7 @@ if ($id > 0 || ! empty($ref)) $outputlangs = $langs; $newlang=''; if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$commande->client->default_lang; + if (empty($newlang)) $newlang=$commande->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 74f50f26a5b..c3f2d28959e 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -123,7 +123,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -152,7 +152,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -410,7 +410,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -515,7 +515,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -612,7 +612,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -647,7 +647,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -668,7 +668,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -688,7 +688,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -750,12 +750,12 @@ if (empty($reshook)) // Recipient was provided from combo list if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party { - $sendto = $object->client->email; + $sendto = $object->thirdparty->email; $sendtoid = 0; } else // Id du contact { - $sendto = $object->client->contact_get_property(GETPOST('receiver'),'email'); + $sendto = $object->thirdparty->contact_get_property(GETPOST('receiver'),'email'); $sendtoid = GETPOST('receiver','alpha'); } } @@ -1277,7 +1277,7 @@ else if ($id > 0 || ! empty($ref)) print '
".$langs->trans("Company").''.$object->client->getNomUrl(1)."
".$langs->trans("Company").''.$object->thirdparty->getNomUrl(1)."
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
"; print '
'; diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 38176068d72..aca31d4e7c2 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -111,7 +111,7 @@ if ($object->id) print ''; // Societe - print "".$langs->trans("Company")."".$object->client->getNomUrl(1).""; + print "".$langs->trans("Company")."".$object->thirdparty->getNomUrl(1).""; print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; print ''.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").''; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 0e11079f476..e209dd741d6 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -975,7 +975,7 @@ class FactureFournisseur extends CommonInvoice } else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { - $num = $this->getNextNumRef($this->client); + $num = $this->getNextNumRef($this->thirdparty); } else { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 59bc805a120..31c2d0aba00 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1184,12 +1184,12 @@ if (empty($reshook)) // Recipient was provided from combo list if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party { - $sendto = $object->client->email; + $sendto = $object->thirdparty->email; $sendtoid = 0; } else // Id du contact { - $sendto = $object->client->contact_get_property(GETPOST('receiver','alpha'),'email'); + $sendto = $object->thirdparty->contact_get_property(GETPOST('receiver','alpha'),'email'); $sendtoid = GETPOST('receiver','alpha'); } } @@ -2451,7 +2451,7 @@ elseif (! empty($object->id)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 64f459886ae..b7e22e9e42f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -976,12 +976,12 @@ if (empty($reshook)) // Recipient was provided from combo list if ($_POST['receiver'] == 'thirdparty') // Id of third party { - $sendto = $object->client->email; + $sendto = $object->thirdparty->email; $sendtoid = 0; } else // Id du contact { - $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); + $sendto = $object->thirdparty->contact_get_property($_POST['receiver'],'email'); $sendtoid = $_POST['receiver']; } } @@ -1120,7 +1120,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -2423,7 +2423,7 @@ else if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 8a815c31edb..9ae66ee685e 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -255,7 +255,7 @@ if ($action == 'builddoc') // En get ou en post $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -413,7 +413,7 @@ if ($action == 'create') // Seems to no be used $outputlangs = $langs; $newlang=''; if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$commande->client->default_lang; + if (empty($newlang)) $newlang=$commande->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -755,7 +755,7 @@ else $outputlangs = $langs; $newlang=''; if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$object->client->default_lang; + if (empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ef126a85b52..4632c7ebb5c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -152,7 +152,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 5f9fc3eacd6..f5675db86f3 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -221,16 +221,16 @@ class SupplierProposal extends CommonObject $productdesc = $prod->description; - $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); - $tva_npr = get_default_npr($mysoc,$this->client,$prod->id); + $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); + $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->client,$tva_npr); - $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->client,$tva_npr); + $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->thirdparty,$tva_npr); + $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->thirdparty,$tva_npr); // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) + if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) { - $price = $prod->multiprices[$this->client->price_level]; + $price = $prod->multiprices[$this->thirdparty->price_level]; } else { @@ -1662,7 +1662,7 @@ class SupplierProposal extends CommonObject if (! empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); } //$ret=$object->fetch($id); // Reload to get new records @@ -1764,7 +1764,7 @@ class SupplierProposal extends CommonObject $values = array( "'".$this->db->idate($now)."'", $product->fk_product, - $this->client->id, + $this->thirdparty->id, "'".$product->ref_fourn."'", $price, $qty, diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index 4e9f3affa50..a3799c0eb29 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -87,10 +87,10 @@ if ($id > 0 || ! empty($ref)) print ''; // Customer - if ( is_null($object->client) ) + if ( is_null($object->thirdparty) ) $object->fetch_thirdparty(); print "".$langs->trans("Supplier").""; - print ''.$object->client->getNomUrl(1).''; + print ''.$object->thirdparty->getNomUrl(1).''; print ''.$langs->trans('SupplierProposalDate').''; print dol_print_date($object->date_livraison,'daytext'); From b59c94e056614f1b20a934948fae6a81d33110f0 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 17 Apr 2016 15:44:04 +0200 Subject: [PATCH 59/78] NEW: Accountancy - Add Result page & review --- htdocs/accountancy/admin/export.php | 6 +- htdocs/accountancy/admin/importaccounts.php | 6 +- htdocs/accountancy/admin/index.php | 16 +- htdocs/accountancy/admin/journal.php | 6 +- htdocs/accountancy/admin/productaccount.php | 10 +- htdocs/accountancy/bookkeeping/balance.php | 2 +- .../bookkeeping/balancebymonth.php | 6 +- htdocs/accountancy/bookkeeping/card.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 2 +- .../class/accountancycategory.class.php | 386 ++++++++++++++++++ .../class/accountancyexport.class.php | 12 +- .../class/accountancysystem.class.php | 6 +- .../class/accountingaccount.class.php | 6 +- .../accountancy/class/bookkeeping.class.php | 24 +- .../class/html.formventilation.class.php | 6 +- htdocs/accountancy/customer/index.html | 0 htdocs/accountancy/customer/index.php | 12 +- htdocs/accountancy/customer/lines.php | 29 +- htdocs/accountancy/journal/index.php | 45 -- .../accountancy/journal/purchasesjournal.php | 6 +- htdocs/accountancy/report/index.html | 0 htdocs/accountancy/report/result.php | 240 +++++++++++ htdocs/accountancy/supplier/index.php | 10 +- htdocs/accountancy/supplier/lines.php | 21 +- .../core/class/html.formaccounting.class.php | 5 +- htdocs/core/lib/accounting.lib.php | 37 -- htdocs/core/menus/init_menu_auguria.sql | 27 +- htdocs/core/menus/standard/eldy.lib.php | 9 +- .../install/mysql/migration/3.9.0-4.0.0.sql | 5 +- .../tables/llx_c_accounting_category.sql | 8 +- htdocs/langs/en_US/accountancy.lang | 35 +- htdocs/langs/en_US/compta.lang | 1 + 32 files changed, 764 insertions(+), 222 deletions(-) create mode 100644 htdocs/accountancy/class/accountancycategory.class.php create mode 100644 htdocs/accountancy/customer/index.html delete mode 100644 htdocs/accountancy/journal/index.php create mode 100644 htdocs/accountancy/report/index.html create mode 100644 htdocs/accountancy/report/result.php diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 1a32c22e12f..7b4ca7f91ce 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -21,9 +21,9 @@ */ /** - * \file htdocs/accountancy/admin/export.php - * \ingroup Accounting Expert - * \brief Setup page to configure accounting expert module + * \file htdocs/accountancy/admin/export.php + * \ingroup Advanced accountancy + * \brief Setup page to configure accounting expert module */ require '../../main.inc.php'; diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 15bd063bf9c..0dc560aa62e 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -19,9 +19,9 @@ */ /** - * \file htdocs/accountancy/admin/importaccounts.php - * \ingroup Accounting Expert - * \brief Page import accounting account + * \file htdocs/accountancy/admin/importaccounts.php + * \ingroup Advanced accountancy + * \brief Page import accounting account */ require '../../main.inc.php'; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 6a63ad433cb..c9041e2a848 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -23,9 +23,9 @@ */ /** - * \file htdocs/accountancy/admin/index.php - * \ingroup Accounting Expert - * \brief Setup page to configure accounting expert module + * \file htdocs/accountancy/admin/index.php + * \ingroup Advanced accountancy + * \brief Setup page to configure accounting expert module */ require '../../main.inc.php'; @@ -38,6 +38,7 @@ $langs->load("compta"); $langs->load("bills"); $langs->load("admin"); $langs->load("accountancy"); +$langs->load("salaries"); // Security check if (! $user->admin) @@ -45,7 +46,7 @@ if (! $user->admin) $action = GETPOST('action', 'alpha'); -// Other parameters ACCOUNTING_* +// Parameters ACCOUNTING_* and others $list = array ( 'ACCOUNTING_LIMIT_LIST_VENTILATION', 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc @@ -63,8 +64,11 @@ $list_account = array ( 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', 'ACCOUNTING_VAT_BUY_ACCOUNT', 'ACCOUNTING_VAT_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_PAY_ACCOUNT', 'ACCOUNTING_ACCOUNT_SUSPENSE', - 'ACCOUNTING_ACCOUNT_TRANSFER_CASH' + 'ACCOUNTING_ACCOUNT_TRANSFER_CASH', + 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', + 'DONATION_ACCOUNTINGACCOUNT' ); /* diff --git a/htdocs/accountancy/admin/journal.php b/htdocs/accountancy/admin/journal.php index e1b76273193..ca4ab67aee8 100644 --- a/htdocs/accountancy/admin/journal.php +++ b/htdocs/accountancy/admin/journal.php @@ -22,9 +22,9 @@ */ /** - * \file htdocs/accountancy/admin/journal.php - * \ingroup Accounting Expert - * \brief Setup page to configure accounting expert module + * \file htdocs/accountancy/admin/journal.php + * \ingroup Advanced accountancy + * \brief Setup page to configure accounting expert module */ require '../../main.inc.php'; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index b7d563c9621..d6f21960a49 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/accountancy/admin/productaccount.php - * \ingroup Accounting Expert - * \brief To define accounting account on product / service + * \file htdocs/accountancy/admin/productaccount.php + * \ingroup Advanced accountancy + * \brief To define accounting account on product / service */ require '../../main.inc.php'; @@ -184,7 +184,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both * View */ -llxHeader('', $langs->trans("Accounts")); +llxHeader('', $langs->trans("InitAccountancy")); print ''."\n"; print ''."\n"; print ''."\n"; + // jQuery Layout (still used by ECM module) + if (defined('REQUIRE_JQUERY_LAYOUT')) + { + print ''."\n"; + } // jQuery jnotify if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) { From bb554a73bd27e56a68e497e715315326926fe066 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 19 Apr 2016 06:18:34 +0200 Subject: [PATCH 68/78] FIX: Accounting library already declared in line 54 --- htdocs/product/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ef126a85b52..cbef61d7590 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -44,7 +44,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.php'; From f0f4933905c3da568b7555ce49716af37e3bad5c Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 16 Apr 2016 11:19:46 +0100 Subject: [PATCH 69/78] new function updateExtraField to update one particular extrafield Conflicts: htdocs/core/class/commonobject.class.php --- htdocs/core/class/commonobject.class.php | 82 ++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7de64135245..2017ef3e873 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -10,6 +10,7 @@ * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Bahfir abbes * * 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 @@ -4237,6 +4238,87 @@ abstract class CommonObject } else return 0; } + /** + * Update an exta field value for the current object. + * Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) + * This function delte record with all extrafields and insert them again from the array $this->array_options. + * $key key of the extrafield + * @return int -1=error, O=did nothing, 1=OK + */ + function updateExtraField($key) + { + global $conf,$langs; + + $error=0; + + if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used + + if (! empty($this->array_options) && !empty($this->array_options["options_$key"])) + { + // Check parameters + $langs->load('admin'); + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); + + $attributeType = $extrafields->attribute_type[$key]; + $attributeLabel = $extrafields->attribute_label[$key]; + $attributeParam = $extrafields->attribute_param[$key]; + switch ($attributeType) + { + case 'int': + if (!is_numeric($value) && $value!='') + { + $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel); + return -1; + } + elseif ($value=='') + { + $this->array_options[$key] = null; + } + break; + case 'price': + $this->array_options[$key] = price2num($this->array_options[$key]); + break; + case 'date': + $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + break; + case 'datetime': + $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + break; + case 'link': + $param_list=array_keys($attributeParam ['options']); + // 0 : ObjectName + // 1 : classPath + $InfoFieldList = explode(":", $param_list[0]); + dol_include_once($InfoFieldList[1]); + $object = new $InfoFieldList[0]($this->db); + if ($value) + { + $object->fetch(0,$value); + $this->array_options[$key]=$object->id; + } + break; + } + + $this->db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET $key=$value"; + $sql .= " WHERE fk_object = ".$this->id; + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + else + { + $this->db->commit(); + return 1; + } + } + else return 0; + } /** * Function to show lines of extrafields with output datas From 62aa6285245260af46a080039b09e5b7606776bc Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 16 Apr 2016 17:41:47 +0100 Subject: [PATCH 70/78] fixmycommit:new function updateExtraField to update one particular extrafield --- htdocs/core/class/commonobject.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2017ef3e873..46278ffcdf4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4261,6 +4261,7 @@ abstract class CommonObject $extrafields = new ExtraFields($this->db); $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); + $value=$this->array_options["options_$key"]; $attributeType = $extrafields->attribute_type[$key]; $attributeLabel = $extrafields->attribute_label[$key]; $attributeParam = $extrafields->attribute_param[$key]; @@ -4274,17 +4275,17 @@ abstract class CommonObject } elseif ($value=='') { - $this->array_options[$key] = null; + $this->array_options["options_$key"] = null; } break; case 'price': - $this->array_options[$key] = price2num($this->array_options[$key]); + $this->array_options["options_$key"] = price2num($this->array_options["options_$key"]); break; case 'date': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + $this->array_options["options_$key"]=$this->db->idate($this->array_options["options_$key"]); break; case 'datetime': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + $this->array_options["options_$key"]=$this->db->idate($this->array_options["options_$key"]); break; case 'link': $param_list=array_keys($attributeParam ['options']); @@ -4296,13 +4297,13 @@ abstract class CommonObject if ($value) { $object->fetch(0,$value); - $this->array_options[$key]=$object->id; + $this->array_options["options_$key"]=$object->id; } break; } $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET $key=$value"; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET $key=".$this->array_options["options_$key"]; $sql .= " WHERE fk_object = ".$this->id; $resql = $this->db->query($sql); if (! $resql) From e673c1aad90fe814d31a2fef8f44d80773cbb16f Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 16 Apr 2016 16:12:50 +0100 Subject: [PATCH 71/78] fix:erroneous nested form --- htdocs/fichinter/card.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 74f50f26a5b..74bd63f2219 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1261,12 +1261,6 @@ else if ($id > 0 || ! empty($ref)) // Print form confirm print $formconfirm; - print ''; - print ''; - if ($action == 'edit_extras') print ''; - if ($action == 'contrat') print ''; - print ''; - print ''; $linkback = ''.$langs->trans("BackToList").''; @@ -1406,8 +1400,6 @@ else if ($id > 0 || ! empty($ref)) print "
"; - print ''; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; From 46190409839ad310834b999f9e7b8a2c755f929e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Apr 2016 11:02:55 +0200 Subject: [PATCH 72/78] Work on website module --- dev/skeletons/skeleton_class.class.php | 2 +- htdocs/admin/websites.php | 10 +- .../install/mysql/migration/3.9.0-4.0.0.sql | 4 +- .../install/mysql/tables/llx_website.key.sql | 2 +- htdocs/install/mysql/tables/llx_website.sql | 2 +- htdocs/langs/en_US/errors.lang | 2 +- htdocs/langs/en_US/website.lang | 10 +- htdocs/theme/eldy/style.css.php | 21 + htdocs/theme/md/style.css.php | 21 + htdocs/websites/class/website.class.php | 39 +- htdocs/websites/class/websitepage.class.php | 651 ++++++++++++++++++ htdocs/websites/index.php | 206 +++++- htdocs/websites/indexold.php | 65 -- 13 files changed, 902 insertions(+), 133 deletions(-) create mode 100644 htdocs/websites/class/websitepage.class.php delete mode 100644 htdocs/websites/indexold.php diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 2e737b8e87f..9a230a05698 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -249,7 +249,7 @@ class Skeleton_Class extends CommonObject $line->prop1 = $obj->field1; $line->prop2 = $obj->field2; - $this->lines[] = $line; + $this->lines[$line->id] = $line; //... } $this->db->free($resql); diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index de4c0472f62..3db5dd93e49 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -75,23 +75,23 @@ $tablib[1] = "Websites"; // Requests to extract data $tabsql=array(); -$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.shortname, f.description, f.status FROM ".MAIN_DB_PREFIX."website as f"; +$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.status FROM ".MAIN_DB_PREFIX."website as f"; // Criteria to sort dictionaries $tabsqlsort=array(); -$tabsqlsort[1] ="shortname ASC"; +$tabsqlsort[1] ="ref ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); -$tabfield[1] = "shortname,description"; +$tabfield[1] = "ref,description"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); -$tabfieldvalue[1] = "shortname,description"; +$tabfieldvalue[1] = "ref,description"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); -$tabfieldinsert[1] = "shortname,description,entity"; +$tabfieldinsert[1] = "ref,description,entity"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 08763bcd9e6..caff6f7001c 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -106,7 +106,7 @@ CREATE TABLE llx_website ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, entity integer DEFAULT 1, - shortname varchar(24) NOT NULL, + ref varchar(24) NOT NULL, description varchar(255), status integer, date_creation datetime, @@ -114,7 +114,7 @@ CREATE TABLE llx_website tms timestamp ) ENGINE=innodb; -ALTER TABLE llx_website ADD UNIQUE INDEX uk_website_shortname (shortname, entity); +ALTER TABLE llx_website ADD UNIQUE INDEX uk_website_ref (ref, entity); CREATE TABLE llx_website_page ( diff --git a/htdocs/install/mysql/tables/llx_website.key.sql b/htdocs/install/mysql/tables/llx_website.key.sql index d25a0009dbe..f3919997476 100644 --- a/htdocs/install/mysql/tables/llx_website.key.sql +++ b/htdocs/install/mysql/tables/llx_website.key.sql @@ -16,5 +16,5 @@ -- -- =========================================================================== -ALTER TABLE llx_website ADD UNIQUE INDEX uk_website_shortname (shortname, entity); +ALTER TABLE llx_website ADD UNIQUE INDEX uk_website_ref (ref, entity); diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website.sql index 81be6720d88..fd8ed4cc39c 100644 --- a/htdocs/install/mysql/tables/llx_website.sql +++ b/htdocs/install/mysql/tables/llx_website.sql @@ -21,7 +21,7 @@ CREATE TABLE llx_website ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, entity integer DEFAULT 1, - shortname varchar(24) NOT NULL, + ref varchar(24) NOT NULL, description varchar(255), status integer, date_creation datetime, diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index c69c49c793a..a3376a336bb 100755 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -85,7 +85,7 @@ ErrorSpecialCharNotAllowedForField=Special characters are not allowed for field ErrorDatabaseParameterWrong=Database setup parameter '%s' has a value not compatible to use Dolibarr (must have value '%s'). ErrorNumRefModel=A reference exists into database (%s) and is not compatible with this numbering rule. Remove record or renamed reference to activate this module. ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier or no price defined on this product for this supplier -ErrorModuleSetupNotComplete=Setup of module looks to be uncomplete. Go on Setup - Modules to complete. +ErrorModuleSetupNotComplete=Setup of module looks to be uncomplete. Go on Home - Setup - Modules to complete. ErrorBadMask=Error on mask ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number ErrorBadMaskBadRazMonth=Error, bad reset value diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 58765929b6c..688866a4e5b 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -2,4 +2,12 @@ Shortname=Code WebsiteSetupDesc=Create here as much entry as number of different websites you need. Then go into menu Websites to edit them. DeleteWebsite=Delete website -ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. \ No newline at end of file +ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. +WEBSITE_PAGENAME=Page name/alias +WEBSITE_URL=Page real URL +EditMenu=Edit menu +EditPageMeta=Edit Meta +EditPageContent=Edit Content +Website=Web site +AddPage=Add page +Page=Page \ No newline at end of file diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ce97dd1c14f..e7fe3a14952 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3104,6 +3104,27 @@ td.hidden { } +/* ============================================================================== */ +/* Module website */ +/* ============================================================================== */ + +.websitebar { + border-bottom: 1px solid #888; + height: 30px; +} +.websiteselection { + display: inline-block; + padding-left: 10px; + vertical-align: middle; + margin-bottom: 5px; + line-height: 29px; +} +.websitetools { + float: right; + padding-top: 2px; +} + + /* ============================================================================== */ /* Module agenda */ /* ============================================================================== */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 30188232239..9b5bbc5966e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2949,6 +2949,27 @@ td.hidden { } +/* ============================================================================== */ +/* Module website */ +/* ============================================================================== */ + +.websitebar { + border-bottom: 1px solid #888; + height: 30px; +} +.websiteselection { + display: inline-block; + padding-left: 10px; + vertical-align: middle; + margin-bottom: 5px; + line-height: 29px; +} +.websitetools { + float: right; + padding-top: 2px; +} + + /* ============================================================================== */ /* Module agenda */ /* ============================================================================== */ diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index 46a0bfe495a..464223a8ed3 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -49,7 +49,7 @@ class Website extends CommonObject public $table_element = 'website'; /** - * @var WebsiteLine[] Lines + * @var WebsitePage[] Lines of all pages */ public $lines = array(); @@ -57,13 +57,15 @@ class Website extends CommonObject */ public $entity; - public $shortname; + public $ref; public $description; public $status; public $date_creation = ''; public $date_modification = ''; public $tms = ''; + public $records; + /** */ @@ -98,8 +100,8 @@ class Website extends CommonObject if (isset($this->entity)) { $this->entity = trim($this->entity); } - if (isset($this->shortname)) { - $this->shortname = trim($this->shortname); + if (isset($this->ref)) { + $this->ref = trim($this->ref); } if (isset($this->description)) { $this->description = trim($this->description); @@ -117,7 +119,7 @@ class Website extends CommonObject $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; $sql.= 'entity,'; - $sql.= 'shortname,'; + $sql.= 'ref,'; $sql.= 'description,'; $sql.= 'status,'; $sql.= 'date_creation,'; @@ -127,7 +129,7 @@ class Website extends CommonObject $sql .= ') VALUES ('; $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; - $sql .= ' '.(! isset($this->shortname)?'NULL':"'".$this->db->escape($this->shortname)."'").','; + $sql .= ' '.(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'").','; $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; @@ -187,7 +189,7 @@ class Website extends CommonObject $sql .= ' t.rowid,'; $sql .= " t.entity,"; - $sql .= " t.shortname,"; + $sql .= " t.ref,"; $sql .= " t.description,"; $sql .= " t.status,"; $sql .= " t.date_creation,"; @@ -211,7 +213,7 @@ class Website extends CommonObject $this->id = $obj->rowid; $this->entity = $obj->entity; - $this->shortname = $obj->shortname; + $this->ref = $obj->ref; $this->description = $obj->description; $this->status = $obj->status; $this->date_creation = $this->db->jdate($obj->date_creation); @@ -255,13 +257,12 @@ class Website extends CommonObject $sql .= ' t.rowid,'; $sql .= " t.entity,"; - $sql .= " t.shortname,"; + $sql .= " t.ref,"; $sql .= " t.description,"; $sql .= " t.status,"; $sql .= " t.date_creation,"; $sql .= " t.date_modification,"; $sql .= " t.tms"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; @@ -282,7 +283,7 @@ class Website extends CommonObject if (!empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } - $this->lines = array(); + $this->records = array(); $resql = $this->db->query($sql); if ($resql) { @@ -294,16 +295,14 @@ class Website extends CommonObject $line->id = $obj->rowid; $line->entity = $obj->entity; - $line->shortname = $obj->shortname; + $line->ref = $obj->ref; $line->description = $obj->description; $line->status = $obj->status; $line->date_creation = $this->db->jdate($obj->date_creation); $line->date_modification = $this->db->jdate($obj->date_modification); $line->tms = $this->db->jdate($obj->tms); - - - $this->lines[] = $line; + $this->records[$line->id] = $line; } $this->db->free($resql); @@ -335,8 +334,8 @@ class Website extends CommonObject if (isset($this->entity)) { $this->entity = trim($this->entity); } - if (isset($this->shortname)) { - $this->shortname = trim($this->shortname); + if (isset($this->ref)) { + $this->ref = trim($this->ref); } if (isset($this->description)) { $this->description = trim($this->description); @@ -354,7 +353,7 @@ class Website extends CommonObject $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; $sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").','; - $sql .= ' shortname = '.(isset($this->shortname)?"'".$this->db->escape($this->shortname)."'":"null").','; + $sql .= ' ref = '.(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").','; $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; @@ -600,7 +599,7 @@ class Website extends CommonObject $this->id = 0; $this->entity = ''; - $this->shortname = ''; + $this->ref = ''; $this->description = ''; $this->status = ''; $this->date_creation = ''; @@ -626,7 +625,7 @@ class WebsiteLine */ public $entity; - public $shortname; + public $ref; public $description; public $status; public $date_creation = ''; diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php new file mode 100644 index 00000000000..a001c8ad56c --- /dev/null +++ b/htdocs/websites/class/websitepage.class.php @@ -0,0 +1,651 @@ + + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file websites/websitepage.class.php + * \ingroup websites + * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * Put some comments here + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class Websitepage + */ +class WebsitePage extends CommonObject +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'websitepage'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'website_page'; + + /** + */ + + public $fk_website; + public $pageurl; + public $title; + public $description; + public $keywords; + public $content; + public $status; + public $date_creation = ''; + public $date_modification = ''; + public $tms = ''; + + /** + */ + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + return 1; + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + // Clean parameters + + if (isset($this->fk_website)) { + $this->fk_website = trim($this->fk_website); + } + if (isset($this->pageurl)) { + $this->pageurl = trim($this->pageurl); + } + if (isset($this->title)) { + $this->title = trim($this->title); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->keywords)) { + $this->keywords = trim($this->keywords); + } + if (isset($this->content)) { + $this->content = trim($this->content); + } + if (isset($this->status)) { + $this->status = trim($this->status); + } + + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; + + $sql.= 'fk_website,'; + $sql.= 'pageurl,'; + $sql.= 'title,'; + $sql.= 'description,'; + $sql.= 'keywords,'; + $sql.= 'content,'; + $sql.= 'status,'; + $sql.= 'date_creation,'; + $sql.= 'date_modification'; + + + $sql .= ') VALUES ('; + + $sql .= ' '.(! isset($this->fk_website)?'NULL':$this->fk_website).','; + $sql .= ' '.(! isset($this->pageurl)?'NULL':"'".$this->db->escape($this->pageurl)."'").','; + $sql .= ' '.(! isset($this->title)?'NULL':"'".$this->db->escape($this->title)."'").','; + $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; + $sql .= ' '.(! isset($this->keywords)?'NULL':"'".$this->db->escape($this->keywords)."'").','; + $sql .= ' '.(! isset($this->content)?'NULL':"'".$this->db->escape($this->content)."'").','; + $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; + $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; + $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'"); + + + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_CREATE',$user); + //if ($result < 0) $error++; + //// End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $website_id Web site page + * @param string $page Page name + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $website_id = null, $page = null) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.fk_website,"; + $sql .= " t.pageurl,"; + $sql .= " t.title,"; + $sql .= " t.description,"; + $sql .= " t.keywords,"; + $sql .= " t.content,"; + $sql .= " t.status,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_modification,"; + $sql .= " t.tms"; + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + if (null !== $website_id) { + $sql .= ' WHERE t.fk_website = ' . '\'' . $website_id . '\''; + $sql .= ' AND t.pageurl = ' . '\'' . $page . '\''; + } else { + $sql .= ' WHERE t.rowid = ' . $id; + } + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->fk_website = $obj->fk_website; + $this->pageurl = $obj->pageurl; + $this->title = $obj->title; + $this->description = $obj->description; + $this->keywords = $obj->keywords; + $this->content = $obj->content; + $this->status = $obj->status; + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_modification = $this->db->jdate($obj->date_modification); + $this->tms = $this->db->jdate($obj->tms); + + + } + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.fk_website,"; + $sql .= " t.pageurl,"; + $sql .= " t.title,"; + $sql .= " t.description,"; + $sql .= " t.keywords,"; + $sql .= " t.content,"; + $sql .= " t.status,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_modification,"; + $sql .= " t.tms"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield,$sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + } + $this->lines = array(); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $line = new WebsitepageLine(); + + $line->id = $obj->rowid; + + $line->fk_website = $obj->fk_website; + $line->pageurl = $obj->pageurl; + $line->title = $obj->title; + $line->description = $obj->description; + $line->keywords = $obj->keywords; + $line->content = $obj->content; + $line->status = $obj->status; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_modification = $this->db->jdate($obj->date_modification); + $line->tms = $this->db->jdate($obj->tms); + + + + $this->lines[$line->id] = $line; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + // Clean parameters + + if (isset($this->fk_website)) { + $this->fk_website = trim($this->fk_website); + } + if (isset($this->pageurl)) { + $this->pageurl = trim($this->pageurl); + } + if (isset($this->title)) { + $this->title = trim($this->title); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->keywords)) { + $this->keywords = trim($this->keywords); + } + if (isset($this->content)) { + $this->content = trim($this->content); + } + if (isset($this->status)) { + $this->status = trim($this->status); + } + + + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + + $sql .= ' fk_website = '.(isset($this->fk_website)?$this->fk_website:"null").','; + $sql .= ' pageurl = '.(isset($this->pageurl)?"'".$this->db->escape($this->pageurl)."'":"null").','; + $sql .= ' title = '.(isset($this->title)?"'".$this->db->escape($this->title)."'":"null").','; + $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; + $sql .= ' keywords = '.(isset($this->keywords)?"'".$this->db->escape($this->keywords)."'":"null").','; + $sql .= ' content = '.(isset($this->content)?"'".$this->db->escape($this->content)."'":"null").','; + $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; + $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; + $sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').','; + $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); + + + $sql .= ' WHERE rowid=' . $this->id; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error && !$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + $this->db->begin(); + + if (!$error) { + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_DELETE',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + } + + if (!$error) { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; + $sql .= ' WHERE rowid=' . $this->id; + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * + * @return int New id of clone + */ + public function createFromClone($fromid) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + global $user; + $error = 0; + $object = new Websitepage($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $result = $object->create($user); + + // Other options + if ($result < 0) { + $error ++; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + + return $object->id; + } else { + $this->db->rollback(); + + return - 1; + } + } + + /** + * Return a link to the user card (with optionaly the picto) + * Use this->id,this->lastname, this->firstname + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to + * @param integer $notooltip 1=Disable tooltip + * @param int $maxlen Max length of visible user name + * @param string $morecss Add more css on link + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') + { + global $langs, $conf, $db; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("MyModule") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $link = 'ref . $linkend; + return $result; + } + + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Renvoi le libelle d'un status donne + * + * @param int $status Id status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function LibStatut($status,$mode=0) + { + global $langs; + + if ($mode == 0) + { + $prefix=''; + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 1) + { + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 2) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 3) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + } + if ($mode == 4) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 5) + { + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + } + } + + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->fk_website = ''; + $this->pageurl = ''; + $this->title = ''; + $this->description = ''; + $this->keywords = ''; + $this->content = ''; + $this->status = ''; + $this->date_creation = ''; + $this->date_modification = ''; + $this->tms = ''; + + + } + +} diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index a975bac297a..bfcdb9e0c85 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -64,6 +64,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; +require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php'; $langs->load("admin"); $langs->load("other"); @@ -71,13 +72,23 @@ $langs->load("website"); if (! $user->admin) accessforbidden(); -$action = GETPOST('action','alpha'); - $conf->dol_hide_leftmenu = 1; +$error=0; +$website=GETPOST('website', 'alpha'); +$page=GETPOST('page', 'alpha'); +$action = GETPOST('action','alpha'); + +if (GETPOST('preview')) $action='preview'; +if (GETPOST('editmeta')) { $action='editmeta'; } +if (GETPOST('editmenu')) { $action='editmenu'; } +if (GETPOST('editcontent')) { $action='editcontent'; } + +if (empty($action)) $action='preview'; + -$website='website1'; $object=new Website($db); +$objectpage=new WebsitePage($db); /* @@ -87,19 +98,43 @@ $object=new Website($db); // Action mise a jour ou ajout d'une constante if ($action == 'update') { - + $db->begin(); + $object->fetch(0, $website); - if (! $res > 0) $error++; - - if (! $error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + $objectpage->fk_website = $object->id; + $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME'); + + $res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl); + + if ($res > 0) + { + $objectpage->title = GETPOST('WEBSITE_TITLE'); + $objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); + $objectpage->keyword = GETPOST('WEBSITE_KEYWORD'); + + $res = $objectpage->update($user); + if (! $res > 0) + { + $error++; + setEventMessages($objectpage->error, $objectpage->errors, 'errors'); + } + + if (! $error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + $action=''; + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db); + } } @@ -109,26 +144,108 @@ if ($action == 'update') * View */ -$_SESSION['website_mode'] = 'edit'; - - $form = new Form($db); $help_url=''; llxHeader('', $langs->trans("WebsiteSetup"), $help_url); -$style=' style="padding-top: 4px; padding-left: 10px; border-bottom: 1px solid #888; height: 20px; vertical-align: middle; margin-bottom: 5px;"'; + print "\n".'
'; + print ''; + print ''; + print ''; + print ''; -print '
'; -// Loop on each sites +$style=''; +if ($action != 'preview') $style=' margin-bottom: 5px;'; + +print ''; + print '
'; + print '
'; + print $langs->trans("Page").': '; + print '
'; + print '
'; + $array=$objectpage->fetchAll(); + print $form->selectarray('page', $array); + print '
'; + print ''; + + print '
'; + + if ($action == 'preview') + { + $disabled=''; + if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; + + if ($page) + { + print ''; + print ''; + } + } + else print ''; + if (preg_match('/^addpage/',$action)) print ''; + + print '
'; + + } } +else +{ + print '
'; + $langs->load("errors"); + print $langs->trans("ErrorModuleSetupNotComplete"); + print '
'; + $action=''; +} + print '
'; @@ -139,12 +256,8 @@ $head = array(); * Edit mode */ -if ($_SESSION['website_mode'] == 'edit') +if ($action == 'editmeta' || $action == 'addpage') { - print "\n".''; - print ''; - print ''; - print ''; print ''; print ''; @@ -152,11 +265,20 @@ if ($_SESSION['website_mode'] == 'edit') print "\n"; print ''; + if ($action != 'addpage') + { + print ''; + } + print '
'.$langs->trans("Description").'
'; - print $langs->trans('WEBSITE_PAGEURL'); + print $langs->trans('WEBSITE_PAGENAME'); print ''; - print '/public/websites/'.$website.'/index.php?page=home'; + print ''; print '
'; + print $langs->trans('WEBSITE_URL'); + print ''; + print '/public/websites/'.$website.'/index.php?page='.urlencode($page); + print '
'; print $langs->trans('WEBSITE_TITLE'); print ''; @@ -178,9 +300,16 @@ if ($_SESSION['website_mode'] == 'edit') print '
'; print '
'; - - - /* +} + +if ($action == 'editmenu') +{ + print '
'.$langs->trans("FeatureNotYetAvailable").''; +} + +if ($action == 'editcontent') +{ +/* * Editing global variables not related to a specific theme */ @@ -197,14 +326,19 @@ if ($_SESSION['website_mode'] == 'edit') require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('WEBSITE_FOOTER',$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); $doleditor->Create(); - - print '
'; - - print ''; } +print ''; + +if ($action == 'preview') +{ + print '
Preview TO DO'; +} + + + llxFooter(); $db->close(); diff --git a/htdocs/websites/indexold.php b/htdocs/websites/indexold.php deleted file mode 100644 index db7b69e1bdd..00000000000 --- a/htdocs/websites/indexold.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * \file htdocs/externalsite/frames.php - * \ingroup externalsite - * \brief Page that build two frames: One for menu, the other for the target page to show - * \author Laurent Destailleur - */ - -require '../main.inc.php'; - -$langs->load("website"); - - -$mainmenu=GETPOST('mainmenu', 'alpha'); -$leftmenu=GETPOST('leftmenu', 'alpha'); -$idmenu=GETPOST('idmenu', 'int'); -$theme=GETPOST('theme', 'alpha'); -$codelang=GETPOST('lang', 'alpha'); - -print " - - -Dolibarr frame for web site menu - - -global->MAIN_MENU_INVERT)?"rows":"cols")."=\"".($heightforframes+50).",*\" border=0 framespacing=0 frameborder=0> - - - - <body> - - </body> - - - - -<body> - <br><div class=\"center\"> - Sorry, your browser is too old or not correctly configured to view this area.<br> - Your browser must support frames.<br> - </div> -</body> - - - -"; - - From 08c379ad58d181c8f8cac54209f39e03bb67f055 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Apr 2016 19:15:31 +0200 Subject: [PATCH 73/78] Fix submit photo is no more hidden on smartphone. --- htdocs/contact/card.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 5dbeeb951dd..a2232358a99 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -972,8 +972,8 @@ else print ''; // Photo - print ''; - print ''.fieldLabel('Photo','photoinput').''; + print ''; + print ''.$langs->trans("PhotoFile").''; print ''; if ($object->photo) { print $form->showphoto('contact',$object); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b3822143167..67fd082c206 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5765,7 +5765,7 @@ class Form if ($caneditfield) { if ($object->photo) $ret.="
\n"; - $ret.=''; + $ret.='
'; if ($object->photo) $ret.=''; $ret.=''; $ret.=''; From c298b783ce8865c3e1cb0ba89cfdf7c251befa78 Mon Sep 17 00:00:00 2001 From: Philippe-OpenDSI Date: Wed, 20 Apr 2016 13:59:13 +0200 Subject: [PATCH 74/78] Product supplier list display only one product Last parameter of select_produits_fournisseurs_list is $limit, not $socidif --- htdocs/product/ajax/products.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index c17fdb65aea..05efcc24a0e 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -183,7 +183,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) if (empty($mode) || $mode == 1) { $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid); } elseif ($mode == 2) { - $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid); + $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson); } $db->close(); From 7bf9c2144e289a928a15e24ae5be837342f1ced5 Mon Sep 17 00:00:00 2001 From: placid0w Date: Wed, 20 Apr 2016 15:43:14 -0300 Subject: [PATCH 75/78] Fix #5054 --- htdocs/webservices/server_productorservice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 2e3314fff12..43facbb24fa 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -374,7 +374,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' $product->load_stock(); $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); - $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos/"; + $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->ref . "/"; $dir = $dir . '/'. $pdir; if (! empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"]; From ffd10a75608eebad55ae782323fe9fc9b5b622f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Apr 2016 02:38:49 +0200 Subject: [PATCH 76/78] Complete function loadExpedition to add filter on fk_product --- htdocs/commande/class/commande.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ae7c18ac077..dc3a3c254a4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1844,13 +1844,13 @@ class Commande extends CommonOrder /** * Load array this->expeditions of lines of shipments with nb of products sent for each order line - * + * Note: For a dedicated shipment, the fetch_lines load the qty_asked and qty_shipped. This function return qty_shipped cuulated for order + * * @param int $filtre_statut Filter on status + * @param int $fk_product Filter on a product * @return int <0 if KO, Nb of lines found if OK - * - * TODO deprecate, move to Shipping class */ - function loadExpeditions($filtre_statut=-1) + function loadExpeditions($filtre_statut=-1, $fk_product=0) { $this->expeditions = array(); @@ -1863,6 +1863,7 @@ class Commande extends CommonOrder if ($filtre_statut >= 0) $sql.= ' ed.fk_expedition = e.rowid AND'; $sql.= ' ed.fk_origin_line = cd.rowid'; $sql.= ' AND cd.fk_commande =' .$this->id; + if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product; if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut; $sql.= ' GROUP BY cd.rowid, cd.fk_product'; //print $sql; From d9e846e5860c4cf5dee2b1948b4a125befb12cb0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Apr 2016 02:47:34 +0200 Subject: [PATCH 77/78] Update migrate script --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index cd74edd4c3f..7ce46730aa9 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -102,6 +102,8 @@ UPDATE llx_projet as p set p.opp_percent = (SELECT percent FROM llx_c_lead_statu ALTER TABLE llx_facturedet ADD COLUMN fk_contract_line integer NULL AFTER rang; ALTER TABLE llx_facturedet_rec ADD COLUMN import_key varchar(14); +--DROP TABLE llx_website_page; +--DROP TABLE llx_website; CREATE TABLE llx_website ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, From c2de7adb327473fc2f80db6d9103967208c81794 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Apr 2016 03:18:42 +0200 Subject: [PATCH 78/78] Minor PHPCS fixes --- ChangeLog | 1 + dev/skeletons/skeleton_class.class.php | 1 - htdocs/categories/class/api_category.class.php | 2 ++ htdocs/websites/class/websitepage.class.php | 10 ++++------ 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec9b5d50ba0..06310ddce07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,7 @@ Following changes may create regression for some external modules, but were nece Dolibarr better: - Function log() of class CommandeFournisseur has been removed. Using it is no more required. - Method select_type_comptes_financiers() has been renamed into selectTypeOfBankAccount() +- Property ->client that was deprecated 6 years ago, is replaced in all core code with ->thirdparty. - File '/core/tpl/document_actions_pre_headers.tpl.php' were renamed into '/core/actions_linkedfiles.inc.php'. So if you included it into your module, change your code like this to be compatible with all version: $res=@include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 9a230a05698..2858e791ce8 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -71,7 +71,6 @@ class Skeleton_Class extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; - return 1; } /** diff --git a/htdocs/categories/class/api_category.class.php b/htdocs/categories/class/api_category.class.php index 5e558ddc486..e17bb273758 100644 --- a/htdocs/categories/class/api_category.class.php +++ b/htdocs/categories/class/api_category.class.php @@ -144,6 +144,7 @@ class CategoryApi extends DolibarrApi $result = $db->query($sql); if ($result) { + $i=0; $num = $db->num_rows($result); while ($i < $num) { @@ -224,6 +225,7 @@ class CategoryApi extends DolibarrApi $result = $db->query($sql); if ($result) { + $i=0; $num = $db->num_rows($result); while ($i < $num) { diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index a001c8ad56c..88b6cee2401 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -55,9 +55,9 @@ class WebsitePage extends CommonObject public $keywords; public $content; public $status; - public $date_creation = ''; - public $date_modification = ''; - public $tms = ''; + public $date_creation; + public $date_modification; + public $tms; /** */ @@ -71,7 +71,6 @@ class WebsitePage extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; - return 1; } /** @@ -546,11 +545,10 @@ class WebsitePage extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - $result = ''; $companylink = ''; - $label = '' . $langs->trans("MyModule") . ''; + $label = '' . $langs->trans("Page") . ''; $label.= '
'; $label.= '' . $langs->trans('Ref') . ': ' . $this->ref;
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'