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/15] 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/15] 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 f3ae67a434db3993980c47dd1f9281df930cac21 Mon Sep 17 00:00:00 2001 From: nka11 Date: Tue, 5 Apr 2016 22:17:52 +0200 Subject: [PATCH 03/15] 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 04/15] 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 d052eac6fc218ac4af9347a86faea14098549425 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 7 Apr 2016 14:57:41 +0200 Subject: [PATCH 05/15] 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 5967330004cac08293dbf64ba71c3e5d1fe2e419 Mon Sep 17 00:00:00 2001 From: nka11 Date: Sat, 9 Apr 2016 21:39:12 +0200 Subject: [PATCH 06/15] 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 d0356d6bd035c629a9e2fcfa2b88b6ec60b31184 Mon Sep 17 00:00:00 2001 From: nka11 Date: Sun, 10 Apr 2016 13:57:53 +0200 Subject: [PATCH 07/15] 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 08/15] 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 09/15] 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 10/15] 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 1fdcd0e859642b400dbd4e2bea344b5882f6b25a Mon Sep 17 00:00:00 2001 From: nka11 Date: Mon, 11 Apr 2016 18:07:02 +0200 Subject: [PATCH 11/15] 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 12/15] 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 13/15] 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 14/15] 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 4eb1aa59aabcdcb67900619333c66d59dc560bf4 Mon Sep 17 00:00:00 2001 From: nka11 Date: Mon, 18 Apr 2016 19:11:28 +0200 Subject: [PATCH 15/15] fix coding rules --- htdocs/commande/class/api_commande.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/commande/class/api_commande.class.php b/htdocs/commande/class/api_commande.class.php index 248cbbcabc4..04d78f30a1d 100644 --- a/htdocs/commande/class/api_commande.class.php +++ b/htdocs/commande/class/api_commande.class.php @@ -234,7 +234,6 @@ class CommandeApi extends DolibarrApi * * * @param int $id Id of order - * @param array $request_data Orderline data * * @url GET order/{id}/line/list *