Merge remote-tracking branch 'uptream/develop' into 8.0-a7

This commit is contained in:
Alexandre SPANGARO 2018-03-08 06:53:54 +01:00
commit 0182b724aa
280 changed files with 11419 additions and 6792 deletions

View File

@ -177,6 +177,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
}*/
}
if (! GETPOST('label','alpha'))
{
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
$ok=0;
}
// Clean some parameters
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
@ -208,7 +213,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
$sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",active)";
$sql.=",active,entity)";
$sql.= " VALUES(";
// List of values
@ -221,11 +226,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1)";
$sql.=",1,".$conf->entity.")";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
@ -275,6 +280,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
$sql.=" AND entity = ".$conf->entity;
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
@ -298,6 +304,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
else { $rowidcol="rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
$sql.=" AND entity = ".$conf->entity;
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
@ -326,6 +333,7 @@ if ($action == $acts[0])
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
}
$sql.=" AND entity = ".$conf->entity;
$result = $db->query($sql);
if (!$result)
@ -346,6 +354,7 @@ if ($action == $acts[1])
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
}
$sql.=" AND entity = ".$conf->entity;
$result = $db->query($sql);
if (!$result)
@ -389,13 +398,7 @@ if ($id)
{
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id];
if ($search_country_id > 0)
{
if (preg_match('/ WHERE /',$sql)) $sql.= " AND ";
else $sql.=" WHERE ";
$sql.= " c.rowid = ".$search_country_id;
}
$sql.= " WHERE a.entity = ".$conf->entity;
if ($sortfield)
{
@ -416,7 +419,6 @@ if ($id)
}
$sql.=$tabsqlsort[$id];
$sql.=$db->plimit($listlimit+1,$offset);
//print $sql;
$fieldlist=explode(',',$tabfield[$id]);

View File

@ -48,7 +48,7 @@ class BookKeeping extends CommonObject
*/
public $table_element = 'accounting_bookkeeping';
public $entity = 1;
public $entity;
/**
* @var BookKeepingLine[] Lines
@ -295,7 +295,7 @@ class BookKeeping extends CommonObject
$sql .= ",'" . $this->db->escape($this->code_journal) . "'";
$sql .= ",'" . $this->db->escape($this->journal_label) . "'";
$sql .= "," . $this->db->escape($this->piece_num);
$sql .= ", " . (! isset($this->entity) ? '1' : $this->entity);
$sql .= ", " . (! isset($this->entity) ? $conf->entity : $this->entity);
$sql .= ")";
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
@ -363,6 +363,8 @@ class BookKeeping extends CommonObject
* @return int <0 if KO, Id of created object if OK
*/
public function createStd(User $user, $notrigger = false, $mode='') {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
@ -486,7 +488,7 @@ class BookKeeping extends CommonObject
$sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ',';
$sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ',';
$sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).',';
$sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity);
$sql .= ' ' . (! isset($this->entity) ? $conf->entity : $this->entity);
$sql .= ')';
$this->db->begin();

View File

@ -455,6 +455,7 @@ if (! $error && $action == 'writebookkeeping') {
// No subledger_account value for the bank line but add a specific label_operation
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $reflabel;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -561,8 +562,8 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->label_compte = '';
}
}
$bookkeeping->label_operation = $reflabel;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -608,8 +609,8 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->date_create = $now;
$bookkeeping->label_compte = '';
$bookkeeping->label_operation = $reflabel;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;

View File

@ -216,6 +216,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -265,6 +266,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -320,6 +322,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;

View File

@ -318,6 +318,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -371,6 +372,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -430,6 +432,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -482,6 +485,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;

View File

@ -121,6 +121,7 @@ if ($in_bookkeeping == 'notyet')
// $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
}
$sql .= " ORDER BY f.datef";
//print $sql;
dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG);
$result = $db->query($sql);
@ -319,6 +320,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -372,6 +374,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -430,6 +433,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
$bookkeeping->entity = $conf->entity;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;

View File

@ -1822,7 +1822,7 @@ else
// Presend form
$modelmail='member';
$defaulttopic='SendMemberRef';
$defaulttopic='CardContent';
$diroutput = $conf->adherent->dir_output;
$trackid = 'mem'.$object->id;

View File

@ -313,10 +313,9 @@ if ($action == 'edit' || $action == 'updateedit')
print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
$var=true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
// Name
@ -411,7 +410,6 @@ if ($action == 'edit' || $action == 'updateedit')
// IDs of the company (country-specific)
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
$var=true;
$langs->load("companies");
@ -697,11 +695,12 @@ else
//print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
//print '</div><br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("CompanyInfo").'</td><td>'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("CompanyName").'</td><td>';
print '<tr class="oddeven"><td class="titlefield wordbreak">'.$langs->trans("CompanyName").'</td><td>';
if (! empty($conf->global->MAIN_INFO_SOCIETE_NOM)) print $conf->global->MAIN_INFO_SOCIETE_NOM;
else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyName")).'</font>';
print '</td></tr>';
@ -791,7 +790,7 @@ else
print '<tr class="oddeven"><td class="tdtop">'.$langs->trans("Note").'</td><td>' . (! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) : '') . '</td></tr>';
print '</table>';
print "</div>";
print '<br>';
@ -799,8 +798,10 @@ else
// IDs of the company (country-specific)
print '<form name="formsoc" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
print '<tr class="liste_titre"><td class="titlefield wordbreak">'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
// Managing Director(s)
@ -956,12 +957,16 @@ else
print '<tr class="oddeven"><td class="tdtop">'.$langs->trans("CompanyObject").'</td><td>' . (! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? nl2br($conf->global->MAIN_INFO_SOCIETE_OBJECT) : '') . '</td></tr>';
print '</table>';
print "</div>";
print '</form>';
/*
* fiscal year beginning
*/
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="titlefield">'.$langs->trans("FiscalYearInformation").'</td><td>'.$langs->trans("Value").'</td>';
@ -973,11 +978,13 @@ else
print dol_print_date(dol_mktime(12,0,0,$monthstart,1,2000,1),'%B','gm') . '</td></tr>';
print "</table>";
print "</div>";
/*
* tax options
*/
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="titlefield">'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>';
@ -1005,7 +1012,7 @@ else
print "</td></tr>\n";
print "</table>";
print "</div>";
/*
* Local Taxes
@ -1014,6 +1021,7 @@ else
{
// Local Tax 1
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="titlefield">'.$langs->transcountry("LocalTax1Management",$mysoc->country_code).'</td><td>'.$langs->trans("Description").'</td>';
@ -1061,11 +1069,13 @@ else
print "</td></tr>\n";
print "</table>";
print "</div>";
}
if ($mysoc->useLocalTax(2)) // True if we found at least on vat with a setup adding a localtax 1
{
// Local Tax 2
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="titlefield">'.$langs->transcountry("LocalTax2Management",$mysoc->country_code).'</td><td>'.$langs->trans("Description").'</td>';
@ -1113,6 +1123,7 @@ else
print "</td></tr>\n";
print "</table>";
print "</div>";
}

View File

@ -611,18 +611,6 @@ else // Show
print '<td>'.$langs->trans("Value").'</td>'."\n";
print "</tr>\n";
if (! empty($dolibarr_pdf_force_fpdf))
{
print '<tr class="oddeven">'."\n";
print '<td>dolibarr_pdf_force_fpdf</td>'."\n";
print '<td>';
print $dolibarr_pdf_force_fpdf;
print '</td>';
print '</tr>';
}
print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans("LibraryToBuildPDF").'</td>'."\n";
print '<td>';
@ -663,11 +651,6 @@ else // Show
print "</table>\n";
print '</div>';
if (! empty($dolibarr_pdf_force_fpdf))
{
print info_admin($langs->trans("WarningUsingFPDF")).'<br>';
}
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>';

View File

@ -116,7 +116,7 @@ if (function_exists('curl_init'))
}
else
{
print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion" class="button">' .$langs->trans("Check").'</a>';
print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion" class="butAction">' .$langs->trans("Check").'</a>';
}
}
@ -325,13 +325,14 @@ $configfileparameters=array(
'?dolibarr_font_DOL_DEFAULT_TTF_BOLD' => 'dolibarr_font_DOL_DEFAULT_TTF_BOLD',
'separator4' => '',
'dolibarr_main_prod' => 'Production mode (Hide all error messages)',
'dolibarr_main_restrict_os_commands' => 'Restrict CLI commands for backups',
'dolibarr_main_restrict_ip' => 'Restrict access to some IPs only',
'?dolibarr_mailing_limit_sendbyweb' => 'Limit nb of email sent by page',
'?dolibarr_mailing_limit_sendbycli' => 'Limit nb of email sent by cli',
'?dolibarr_strict_mode' => 'Strict mode is on/off',
'?dolibarr_pdf_force_fpdf' => 'Force fpdf usage to generate PDF'
'?dolibarr_strict_mode' => 'Strict mode is on/off',
'?dolibarr_nocsrfcheck' => 'Disable CSRF security checks'
);
$var=true;
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
@ -441,8 +442,8 @@ if ($resql)
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="tdoverflow">'.$obj->name.'</td>'."\n";
print '<td class="tdoverflow">'.$obj->value.'</td>'."\n";
print '<td class="tdoverflowmax300">'.$obj->name.'</td>'."\n";
print '<td class="tdoverflowmax300">'.dol_escape_htmltag($obj->value).'</td>'."\n";
if (empty($conf->multicompany->enabled) || !$user->entity) print '<td align="center" width="80px">'.$obj->entity.'</td>'."\n"; // If superadmin or multicompany disabled
print "</tr>\n";

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015-2018 Alexandre Spangaro <aspangaro@zendsi.com>
*
* 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
@ -30,17 +30,20 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
$langs->load('admin');
$langs->load('objects');
$langs->load("companies");
$langs->load("products");
if (!$user->admin) accessforbidden();
$action = GETPOST('action','alpha');
// Other parameters ACCOUNTING_*
// Other parameters
$list = array (
'ACCOUNTING_VAT_PAY_ACCOUNT'
);
/*
* Actions
*/
@ -60,137 +63,174 @@ $list = array (
$tax_mode = empty($conf->global->TAX_MODE)?0:$conf->global->TAX_MODE;
if ($action == 'update') {
$error = 0;
$error = 0;
// Tax mode
$tax_mode = GETPOST('tax_mode','alpha');
$db->begin();
$db->begin();
$res = dolibarr_set_const($db, 'TAX_MODE', $tax_mode,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, 'TAX_MODE', $tax_mode,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
switch ($tax_mode)
{
case 0:
$value = 'payment';
break;
case 1:
$value = 'invoice';
break;
}
switch ($tax_mode)
{
case 0:
$value = 'payment';
break;
case 1:
$value = 'invoice';
break;
}
$res = dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', $value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', $value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', $value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', $value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_INFO_VAT_RETURN", GETPOST("MAIN_INFO_VAT_RETURN",'alpha'),'chaine',0,'',$conf->entity);
// Others options
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if (! $error) {
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
if (! $error) {
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
$db->rollback();
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
/*
* View
*/
llxHeader();
llxHeader('', $langs->trans("TaxSetup"));
$form=new Form($db);
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('TaxSetup'),$linkback,'title_setup');
dol_fiche_head();
//dol_fiche_head(null, '', '', -1);
if (empty($mysoc->tva_assuj))
{
print $langs->trans("YourCompanyDoesNotUseVAT").'<br>';
print $langs->trans("YourCompanyDoesNotUseVAT").'<br>';
}
else
{
print '<table class="noborder" width="100%">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
// Cas des parametres TAX_MODE_SELL/BUY_SERVICE/PRODUCT
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
print "</tr>\n";
print '<tr class="oddeven"><td width="200"><input type="radio" name="tax_mode" value="0"'.($tax_mode != 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDefaultDesc'));
print "</td></tr>\n";
print '<tr class="oddeven"><td width="200"><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."</td></tr>\n";
print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
print '<input name="tva" id="intra_vat" class="minwidth200" value="' . (! empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '') . '">';
print '</td></tr>';
print "</table>\n";
print '<tr class="oddeven"><td><label for="activate_MAIN_INFO_VAT_RETURN">'.$langs->trans("VATReturn").'</label></td>';
if (! $conf->use_javascript_ajax)
{
print '<td class="nowrap" align="right">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print "</td>";
}
else
{
print '<td width="120">';
$listval=array('0'=>$langs->trans(""),
'1'=>$langs->trans("Monthly"),
'2'=>$langs->trans("Quarterly"),
'3'=>$langs->trans("Annual"),
);
print $form->selectarray("MAIN_INFO_VAT_RETURN", $listval, $conf->global->MAIN_INFO_VAT_RETURN);
print "</td>";
}
print '</tr>';
print '<br>';
print load_fiche_titre($langs->trans("SummaryOfVatExigibilityUsedByDefault"),'','');
//print ' ('.$langs->trans("CanBeChangedWhenMakingInvoice").')';
print '</table>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>&nbsp;</td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
print "<br>\n";
// Products
print '<tr class="oddeven"><td>'.$langs->trans("Product").'</td>';
print '<td>';
print $langs->trans("OnDelivery");
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
print '</td>';
print '<td>';
print $langs->trans("OnDelivery");
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
print '</td></tr>';
print '<table class="noborder" width="100%">';
// Services
print '<tr class="oddeven"><td>'.$langs->trans("Services").'</td>';
print '<td>';
if ($tax_mode == 0)
{
print $langs->trans("OnPayment");
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
}
if ($tax_mode == 1)
{
print $langs->trans("OnInvoice");
print ' ('.$langs->trans("InvoiceDateUsed").')';
}
print '</td>';
print '<td>';
if ($tax_mode == 0)
{
print $langs->trans("OnPayment");
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
}
if ($tax_mode == 1)
{
print $langs->trans("OnInvoice");
print ' ('.$langs->trans("InvoiceDateUsed").')';
}
print '</td></tr>';
// Cas des parametres TAX_MODE_SELL/BUY_SERVICE/PRODUCT
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
print "</tr>\n";
print '<tr class="oddeven"><td width="200"><input type="radio" name="tax_mode" value="0"'.($tax_mode != 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDefaultDesc'));
print "</td></tr>\n";
print '<tr class="oddeven"><td width="200"><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."</td></tr>\n";
print '</table>';
print "</table>\n";
print '<br>';
print load_fiche_titre($langs->trans("SummaryOfVatExigibilityUsedByDefault"),'','');
//print ' ('.$langs->trans("CanBeChangedWhenMakingInvoice").')';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>&nbsp;</td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
// Products
print '<tr class="oddeven"><td>'.$langs->trans("Product").'</td>';
print '<td>';
print $langs->trans("OnDelivery");
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
print '</td>';
print '<td>';
print $langs->trans("OnDelivery");
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
print '</td></tr>';
// Services
print '<tr class="oddeven"><td>'.$langs->trans("Services").'</td>';
print '<td>';
if ($tax_mode == 0)
{
print $langs->trans("OnPayment");
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
}
if ($tax_mode == 1)
{
print $langs->trans("OnInvoice");
print ' ('.$langs->trans("InvoiceDateUsed").')';
}
print '</td>';
print '<td>';
if ($tax_mode == 0)
{
print $langs->trans("OnPayment");
print ' ('.$langs->trans("SupposedToBePaymentDate").')';
}
if ($tax_mode == 1)
{
print $langs->trans("OnInvoice");
print ' ('.$langs->trans("InvoiceDateUsed").')';
}
print '</td></tr>';
print '</table>';
}
print "<br>\n";
@ -205,12 +245,10 @@ print "</tr>\n";
foreach ($list as $key)
{
print '<tr class="oddeven value">';
// Param
$label = $langs->trans($key);
$label = $langs->trans($key);
print '<td><label for="'.$key.'">'.$label.'</label></td>';
// Value
@ -228,7 +266,9 @@ foreach ($list as $key)
print '</table>';
dol_fiche_end();
//dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="button">';

View File

@ -196,7 +196,7 @@ else if (GETPOST('downloadcsv','alpha'))
$block_static->user_fullname = $obj->user_fullname;
$block_static->fk_user = $obj->fk_user;
$block_static->signature = $obj->signature;
$block_static->object_data = unserialize($obj->object_data);
$block_static->object_data = $block_static->dolDecodeBlockedData($obj->object_data);
$checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it

View File

@ -85,10 +85,16 @@ function formatObject($objtoshow, $prefix)
{
if (! is_object($val) && ! is_array($val))
{
// TODO $val can be '__PHP_Incomplete_Class', the is_object return false
$s.='<tr><td>'.($prefix?$prefix.' > ':'').$key.'</td>';
$s.='<td>';
if (in_array($key, array('date','datef','dateh','datec','datem','datep')))
{
/*var_dump(is_object($val));
var_dump(is_array($val));
var_dump(is_array($val));
var_dump(@get_class($val));
var_dump($val);*/
$s.=dol_print_date($val, 'dayhour');
}
else

View File

@ -18,10 +18,23 @@
* See https://medium.com/@lhartikk/a-blockchain-in-200-lines-of-code-963cc1cc0e54
*/
/*ini_set('unserialize_callback_func', 'mycallback');
function mycallback($classname)
{
//var_dump($classname);
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
}*/
/**
* Class to manage Blocked Log
*/
class BlockedLog
{
/**
@ -636,7 +649,7 @@ class BlockedLog
$this->fk_user = $obj->fk_user;
$this->user_fullname = $obj->user_fullname;
$this->object_data = unserialize($obj->object_data);
$this->object_data = $this->dolDecodeBlockedData($obj->object_data);
$this->signature = $obj->signature;
$this->signature_line = $obj->signature_line;
@ -658,6 +671,31 @@ class BlockedLog
}
/**
* Decode data
*
* @param string $data Data to unserialize
* @param string $mode 0=unserialize, 1=json_decode
* @return string Value unserialized
*/
public function dolDecodeBlockedData($data, $mode=0)
{
try
{
//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
//include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$aaa = unserialize($data);
//$aaa = unserialize($data);
}
catch(Exception $e)
{
//print $e->getErrs);
}
return $aaa;
}
/**
* Set block certified by authority
*

View File

@ -1044,7 +1044,7 @@ if ($id > 0)
}
// Title
print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").'</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="'.$object->label.'"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("Title").'</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="'.$object->label.'"></td></tr>';
// Full day event
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent?' checked':'').'></td></tr>';

View File

@ -1236,8 +1236,12 @@ class ActionComm extends CommonObject
$result='';
// Set label of typ
$labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label;
// Set label of type
$labeltype = '';
if ($this->type_code)
{
$labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label;
}
if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL');
@ -1289,7 +1293,7 @@ class ActionComm extends CommonObject
$linkstart.=$linkclose.'>';
$linkend='</a>';
//print 'rrr'.$this->libelle.'-'.$withpicto;
//print 'rrr'.$this->libelle.'rrr'.$this->label.'rrr'.$withpicto;
if ($withpicto == 2)
{
@ -1309,7 +1313,10 @@ class ActionComm extends CommonObject
{
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into ()
{
$libelle.=(($this->type_code && $libelle!=$langs->transnoentities("Action".$this->type_code) && $langs->transnoentities("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->transnoentities("Action".$this->type_code).')':'');
if ($labeltype)
{
$libelle.=(preg_match('/'.preg_quote($labeltype,'/').'/', $libelle)?'':' ('.$langs->transnoentities("Action".$this->type_code).')');
}
}
}

View File

@ -589,6 +589,7 @@ if ($resql)
$event->type_color=$obj->type_color;
$event->libelle=$obj->label;
$event->label=$obj->label;
$event->percentage=$obj->percent;
$event->authorid=$obj->fk_user_author; // user id of creator
$event->userownerid=$obj->fk_user_action; // user id of owner
@ -601,7 +602,9 @@ if ($resql)
$event->elementtype=$obj->elementtype;
$event->societe->id=$obj->fk_soc;
$event->thirdparty_id=$obj->fk_soc;
$event->contact->id=$obj->fk_contact;
$event->contact_id=$obj->fk_contact;
// Defined date_start_in_calendar and date_end_in_calendar property
// They are date start and end of action but modified to not be outside calendar view.
@ -1176,19 +1179,72 @@ else // View by day
$timestamp=dol_mktime(12,0,0,$month,$day,$year);
$arraytimestamp=dol_getdate($timestamp);
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
echo '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
echo ' <tr class="liste_titre">';
echo ' <td align="center">'.$langs->trans("Day".$arraytimestamp['wday'])."</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo ' <td class="'.$style.'" width="14%" valign="top">';
$maxnbofchar=80;
show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
echo "</td>\n";
echo " </tr>\n";
//echo '<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month">';
echo '<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
echo ' <tr class="tagtr liste_titre">';
echo ' <td class="tagtd width100"></td>';
echo ' <td class="tagtd center">'.$langs->trans("Day".$arraytimestamp['wday'])."</td>\n";
echo " </td>\n";
/*
echo ' <div class="tagtr">';
echo ' <div class="tagtd width100"></div>';
echo ' <div class="tagtd center">';
echo show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, -1);
echo ' </div>'."\n";
echo " </div>\n";
*/
echo '</table>';
print '</div>';
/* WIP View per hour */
$useviewhour = 0;
if ($useviewhour)
{
print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500)?($_SESSION["dol_screenheight"]-200):660; // Also into index.php file
echo '<div style="max-height: '.$maxheightwin.'px;">';
echo '<div class="tagtable centpercent calendarviewcontainer">';
$maxnbofchar=80;
$tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
$minhour = round($tmp[0],0);
$maxhour = round($tmp[1],0);
if ($minhour > 23) $minhour = 23;
if ($maxhour < 1) $maxhour = 1;
if ($maxhour <= $minhour) { $maxhour = $minhour + 1; }
$i = 0;
$j = 0;
while ($i < 24)
{
echo ' <div class="tagtr calendarviewcontainertr">'."\n";
echo ' <div class="tagtd width100 tdtop">'.dol_print_date($i*3600, 'hour', 'gmt').'</div>';
echo ' <div class="tagtd '.$style.' tdtop">';
echo " </div>\n";
echo " </div>\n";
$i++;
$j++;
}
echo '</div></div>';
show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
print '</div>';
}
else
{
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
print '</div>';
}
}
print "\n".'</form>';
@ -1213,9 +1269,10 @@ $db->close();
* @param string $newparam Parameters on current URL
* @param int $showinfo Add extended information (used by day and week view)
* @param int $minheight Minimum height for each event. 60px by default.
* @param string $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button"
* @return void
*/
function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60)
function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $nonew=0)
{
global $user, $conf, $langs;
global $action, $filter, $filtert, $status, $actioncode; // Filters used into search form
@ -1230,26 +1287,35 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$curtime = dol_mktime(0, 0, 0, $month, $day, $year);
print '<div id="dayevent_'.$dateint.'" class="dayevent tagtable centpercent nobordernopadding">'."\n";
print '<div class="tagtr"><div class="nowrap float">';
print '<a style="color: #666" href="'.DOL_URL_ROOT.'/comm/action/index.php?';
print 'action=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year;
print $newparam;
print '">';
if ($showinfo) print dol_print_date($curtime,'daytextshort');
else print dol_print_date($curtime,'%d');
print '</a>';
print '</div><div class="floatright nowrap">';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
if ($nonew <= 0)
{
$newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year;
print '<div class="tagtr"><div class="nowrap float">';
print '<a style="color: #666" href="'.DOL_URL_ROOT.'/comm/action/index.php?';
print 'action=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year;
print $newparam;
print '">';
if ($showinfo) print dol_print_date($curtime,'daytextshort');
else print dol_print_date($curtime,'%d');
print '</a>';
print '</div><div class="floatright nowrap">';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
{
$newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year;
//$param='month='.$monthshown.'&year='.$year;
$hourminsec='100000';
print '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$year,$month,$day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'">';
print img_picto($langs->trans("NewAction"),'edit_add.png');
print '</a>';
//$param='month='.$monthshown.'&year='.$year;
$hourminsec='100000';
print '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$year,$month,$day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'">';
print img_picto($langs->trans("NewAction"),'edit_add.png');
print '</a>';
}
print '</div></div>'."\n";
}
if ($nonew < 0)
{
print '</div>';
return;
}
print '</div></div>'."\n";
// Line with td contains all div of each events
print '<div class="tagtr">';
@ -1390,6 +1456,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
//print ' position: absolute; top: 40px; width: 50%;';
//print '"';
print '>';
//var_dump($event->userassigned);
//var_dump($event->transparency);
print '<table class="centpercent cal_event'.(empty($event->transparency)?' cal_event_notbusy':' cal_event_busy').'" style="'.$h;
@ -1475,10 +1542,12 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
if ($event->type_code == 'ICALEVENT') print $titletoshow;
else
{
$savlabel=$event->libelle;
$event->libelle=$titletoshow;
print $event->getNomUrl(0,$maxnbofchar,'cal_event','',0,1);
$event->libelle=$savlabel;
$savlabel=$event->label?$event->label:$event->libelle;
$event->label=$titletoshow;
$event->libelle=$titletoshow;
print $event->getNomUrl(0,$maxnbofchar,'cal_event','',0,1);
$event->label=$savlabel;
$event->libelle=$savlabel;
}
// Loop on each assigned user
@ -1495,7 +1564,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$cacheusers[$tmpid]=$newuser;
}
$listofusertoshow.=$cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valigntextbottom');
$listofusertoshow.=$cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom');
}
print $listofusertoshow;

View File

@ -331,13 +331,9 @@ if ($resql)
$num = $db->num_rows($resql);
/*$title=$langs->trans("DoneAndToDoActions");
if ($status == 'done') $title=$langs->trans("DoneActions");
if ($status == 'todo') $title=$langs->trans("ToDoActions");
*/
$title=$langs->trans("ListOfEvents");
$newtitle=$langs->trans($title);
// Local calendar
$newtitle ='<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda").' &nbsp; </div>';
//$newtitle=$langs->trans($title);
$tabactive='cardlist';
@ -430,12 +426,12 @@ if ($resql)
if (! empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>';
if (! empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
if (! empty($arrayfields['a.datep']['checked'])) {
print '<td class="liste_titre" align="center">';
print '<td class="liste_titre nowraponall" align="center">';
print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1);
print '</td>';
}
if (! empty($arrayfields['a.datep2']['checked'])) {
print '<td class="liste_titre" align="center">';
print '<td class="liste_titre nowraponall" align="center">';
print $form->select_date($dateend, 'dateend', 0, 0, 1, '', 1, 0, 1);
print '</td>';
}
@ -517,8 +513,8 @@ if ($resql)
print '<tr class="oddeven">';
// Ref
if (! empty($arrayfields['a.id']['checked'])) {
// Ref
print '<td>';
print $actionstatic->getNomUrl(1,-1);
print '</td>';

View File

@ -670,7 +670,7 @@ if ($resql)
// Status billed
if (! empty($arrayfields['c.facture']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone" align="right">';
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
print $form->selectyesno('billed', $billed, 1, 0, 1);
print '</td>';
}

View File

@ -673,7 +673,7 @@ if ($resql)
print '</td>';
print '<td>&nbsp;</td>';
print '<td class="nowrap">';
$form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1);
$form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')), 'operation', '1,2', 2, 1);
print '</td>';
print '<td>';
print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq","alpha").'">';
@ -852,7 +852,7 @@ if ($resql)
if (! empty($arrayfields['type']['checked']))
{
print '<td class="liste_titre" align="center">';
$form->select_types_paiements(empty($search_type)?'':$search_type, 'search_type', '', 2, 0, 1, 0, 1, 'maxwidth100');
$form->select_types_paiements(empty($search_type)?'':$search_type, 'search_type', '', 2, 1, 1, 0, 1, 'maxwidth100');
print '</td>';
}
if (! empty($arrayfields['b.num_chq']['checked']))

View File

@ -187,7 +187,7 @@ if ($result)
// Type
print '<td class="liste_titre" align="left">';
$form->select_types_paiements($typeid,'typeid','',0,0,1,16);
$form->select_types_paiements($typeid,'typeid','',0,1,1,16);
print '</td>';
// Account

View File

@ -419,19 +419,19 @@ if ($resql)
// Date invoice
if (! empty($arrayfields['f.date_last_gen']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5);
print '<td class="liste_titre nowraponall" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle');
print '</td>';
}
// Date next generation
if (! empty($arrayfields['f.date_when']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="search_month_date_when" value="'.$search_month_date_when.'">';
$formother->select_year($search_year_date_when?$search_year_date_when:-1,'search_year_date_when',1, 20, 5);
print '<td class="liste_titre nowraponall" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">';
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month_date_when" value="'.$search_month_date_when.'">';
$formother->select_year($search_year_date_when?$search_year_date_when:-1,'search_year_date_when',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle');
print '</td>';
}
// Extra fields

View File

@ -701,19 +701,19 @@ if ($resql)
// Date invoice
if (! empty($arrayfields['f.date']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.dol_escape_htmltag($month).'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print '<td class="liste_titre nowraponall" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">';
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="month" value="'.dol_escape_htmltag($month).'">';
$formother->select_year($year?$year:-1,'year',1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
print '</td>';
}
// Date due
if (! empty($arrayfields['f.date_lim_reglement']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_lim" value="'.dol_escape_htmltag($month_lim).'">';
$formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5);
print '<td class="liste_titre nowraponall" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="day_lim" value="'.dol_escape_htmltag($day_lim).'">';
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="month_lim" value="'.dol_escape_htmltag($month_lim).'">';
$formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
print '<br><input type="checkbox" name="option" value="late"'.($option == 'late'?' checked':'').'> '.$langs->trans("Late");
print '</td>';
}
@ -756,7 +756,7 @@ if ($resql)
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
{
print '<td class="liste_titre" align="left">';
$form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1, 10);
$form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10);
print '</td>';
}
if (! empty($arrayfields['f.total_ht']['checked']))
@ -775,14 +775,14 @@ if ($resql)
}
if (! empty($arrayfields['f.total_localtax1']['checked']))
{
// Amount
// Localtax1
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.$search_montant_localtax1.'">';
print '</td>';
}
if (! empty($arrayfields['f.total_localtax2']['checked']))
{
// Amount
// Localtax2
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.$search_montant_localtax2.'">';
print '</td>';

View File

@ -332,21 +332,22 @@ if ($resql)
if ($num > 0)
{
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
$thirdpartystatic->fetch($objp->socid);
$invoice=new Facture($db);
$invoice->fetch($objp->facid);
$paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed();
$deposits=$invoice->getSumDepositsUsed();
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
$invoice=new Facture($db);
$invoice->fetch($objp->facid);
$paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed();
$deposits=$invoice->getSumDepositsUsed();
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
print '<tr class="oddeven">';
// Invoice
print '<td>';
@ -355,8 +356,6 @@ if ($resql)
// Third party
print '<td>';
$thirdpartystatic->id=$objp->socid;
$thirdpartystatic->name=$objp->name;
print $thirdpartystatic->getNomUrl(1);
print '</td>';

View File

@ -255,7 +255,7 @@ if ($modecompta == 'BOOKKEEPING')
$sql.= " WHERE f.numero_compte = aa.account_number";
//$sql.= " AND fk_statut in (1,2)";
$sql.= " AND ".$predefinedgroupwhere;
$sql.= " AND aa.fk_pcg_version = '".$charofaccountstring."'";
$sql.= " AND f.entity = ".$conf->entity;
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY pcg_type, pcg_subtype, name, socid";

View File

@ -828,7 +828,6 @@ if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING'))
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND b.doc_date >= '".$db->idate($date_start)."' AND b.doc_date <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, dm";
//print $sql;
dol_syslog("get bookkeeping record");

View File

@ -179,7 +179,7 @@ if ($result)
print '<td class="liste_titre">&nbsp;</td>';
// Type
print '<td class="liste_titre" align="left">';
$form->select_types_paiements($typeid,'typeid','',0,0,1,16);
$form->select_types_paiements($typeid,'typeid','',0,1,1,16);
print '</td>';
// Account
if (! empty($conf->banque->enabled))

View File

@ -142,9 +142,7 @@ else if ($modecompta=="BOOKKEEPING")
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded");
$description=$langs->trans("RulesCATotalSaleJournal");
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
@ -187,15 +185,14 @@ if ($socid) $sql.= " AND f.fk_soc = ".$socid;
else if ($modecompta=="BOOKKEEPING")
{
$sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql.= " WHERE b.numero_compte IN (SELECT a.account_number" ;
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_account as a";
$sql.= " WHERE a.fk_accounting_category = 1 ) " ; // todo sql with accounting category, but we need to define category in turnover
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj";
$sql.= " WHERE b.entity = ".$conf->entity;
$sql.= " AND b.code_journal = aj.code AND aj.nature = 2" ; // @TODO currently count amount in sale journal, but we need to define a category group for turnover
}
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";
//print $sql;
$result = $db->query($sql);
if ($result)
@ -221,7 +218,7 @@ else {
}
// On ajoute les paiements anciennes version, non lies par paiement_facture (very old versions)
if ($modecompta != 'CREANCES-DETTES')
if ($modecompta == 'RECETTES-DEPENSES')
{
$sql = "SELECT date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
@ -269,10 +266,11 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
if ($modecompta == 'CREANCES-DETTES') print '<td align="center" width="10%" colspan="3">';
else print '<td align="center" width="10%" colspan="2" class="borderrightlight">';
print '<a href="casoc.php?year='.$annee.'">';
if ($modecompta != 'BOOKKEEPING') print '<a href="casoc.php?year='.$annee.'">';
print $annee;
if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) print '-'.($annee+1);
print '</a></td>';
if ($modecompta != 'BOOKKEEPING') print '</a>';
print '</td>';
if ($annee != $year_end) print '<td width="15">&nbsp;</td>';
}
print '</tr>';
@ -336,7 +334,9 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
if ($cum[$case])
{
$now_show_delta=1; // On a trouve le premier mois de la premiere annee generant du chiffre.
print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">'.price($cum[$case],1).'</a>';
if ($modecompta != 'BOOKKEEPING') print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta?'&modecompta='.$modecompta:'').'">';
print price($cum[$case], 1);
if ($modecompta != 'BOOKKEEPING') print '</a>';
}
else
{

View File

@ -173,7 +173,7 @@ if ($result)
print '</td>';
// Type
print '<td class="liste_titre" align="left">';
$form->select_types_paiements($typeid,'typeid','',0,0,1,16);
$form->select_types_paiements($typeid,'typeid','',0,1,1,16);
print '</td>';
// Account
if (! empty($conf->banque->enabled))

View File

@ -686,6 +686,35 @@ if ($massaction == 'confirm_createbills')
{
$db->commit();
setEventMessage($langs->trans('BillCreated', $nb_bills_created));
// Make a redirect to avoid to bill twice if we make a refresh or back
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($sall) $param.='&sall='.urlencode($sall);
if ($socid > 0) $param.='&socid='.urlencode($socid);
if ($viewstatut != '') $param.='&viewstatut='.urlencode($viewstatut);
if ($search_orderday) $param.='&search_orderday='.urlencode($search_orderday);
if ($search_ordermonth) $param.='&search_ordermonth='.urlencode($search_ordermonth);
if ($search_orderyear) $param.='&search_orderyear='.urlencode($search_orderyear);
if ($search_deliveryday) $param.='&search_deliveryday='.urlencode($search_deliveryday);
if ($search_deliverymonth) $param.='&search_deliverymonth='.urlencode($search_deliverymonth);
if ($search_deliveryyear) $param.='&search_deliveryyear='.urlencode($search_deliveryyear);
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
if ($search_company) $param.='&search_company='.urlencode($search_company);
if ($search_ref_customer) $param.='&search_ref_customer='.urlencode($search_ref_customer);
if ($search_user > 0) $param.='&search_user='.urlencode($search_user);
if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
if ($search_total_ht != '') $param.='&search_total_ht='.urlencode($search_total_ht);
if ($search_total_vat != '') $param.='&search_total_vat='.urlencode($search_total_vat);
if ($search_total_ttc != '') $param.='&search_total_ttc='.urlencode($search_total_ttc);
if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref);
if ($show_files) $param.='&show_files=' .urlencode($show_files);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if ($billed != '') $param.='&billed='.urlencode($billed);
header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
exit;
}
else
{

View File

@ -136,7 +136,7 @@ class box_commandes extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax100"',
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $societestatic->getNomUrl(1),
'asis' => 1,
);

View File

@ -128,7 +128,7 @@ class box_contracts extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $thirdpartytmp->getNomUrl(1),
'asis'=>1
);

View File

@ -131,13 +131,13 @@ class box_produits extends ModeleBoxes
$productstatic->entity = $objp->entity;
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $productstatic->getNomUrl(1),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $objp->label,
);

View File

@ -144,7 +144,7 @@ class box_produits_alerte_stock extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $objp->label,
);

View File

@ -131,13 +131,13 @@ class box_propales extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax100"',
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $societestatic->getNomUrl(1),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'td' => 'class="right nowraponall"',
'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
);

View File

@ -177,7 +177,7 @@ class box_services_contracts extends ModeleBoxes
}
$this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
$this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $s,
'asis' => 1
);
@ -187,7 +187,7 @@ class box_services_contracts extends ModeleBoxes
'asis' => 1
);
$this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
$this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $thirdpartytmp->getNomUrl(1),
'asis' => 1
);

View File

@ -126,7 +126,7 @@ class box_services_expired extends ModeleBoxes
'asis' => 1
);
$this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone" align="left"',
$this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax150 maxwidth150onsmartphone" align="left"',
'text' => $thirdpartytmp->getNomUrl(1, 'customer'),
'asis' => 1
);

View File

@ -248,7 +248,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
$out.= '>';
if ($conf->use_javascript_ajax)
{
$out.= '<table summary="" class="nobordernopadding" width="100%"><tr><td class="tdoverflowmax100 maxwidth100onsmartphone">';
$out.= '<table summary="" class="nobordernopadding" width="100%"><tr><td class="tdoverflowmax150 maxwidth150onsmartphone">';
}
if (! empty($head['text']))
{

View File

@ -7,20 +7,22 @@ class Comment extends CommonObject
public $element='comment'; //!< Id that identify managed objects
public $table_element='comment'; //!< Name of table without prefix where object is stored
var $fk_element;
var $element_type;
public $fk_element;
public $element_type;
var $description;
public $description;
var $tms;
public $tms;
var $datec;
public $datec;
var $fk_user_author;
public $fk_user_author;
var $entity;
public $entity;
var $import_key;
public $import_key;
public $comments = array();
public $oldcopy;
@ -289,10 +291,10 @@ class Comment extends CommonObject
* @param int $fk_element Id of element
* @return array Comment array
*/
public static function fetchAllFor($element_type, $fk_element)
public function fetchAllFor($element_type, $fk_element)
{
global $db,$conf;
$TComments = array();
$this->comments = array();
if(!empty($element_type) && !empty($fk_element)) {
$sql = "SELECT";
$sql.= " c.rowid";
@ -302,7 +304,7 @@ class Comment extends CommonObject
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " ORDER BY c.tms DESC";
dol_syslog("Comment::fetchAllFor", LOG_DEBUG);
dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
@ -313,12 +315,17 @@ class Comment extends CommonObject
{
$comment = new self($db);
$comment->fetch($obj->rowid);
$TComments[] = $comment;
$this->comments[] = $comment;
}
}
$db->free($resql);
} else {
$error++; $this->errors[]="Error ".$this->db->lasterror();
return -1;
}
}
return $TComments;
return count($this->comments);
}
}

View File

@ -6678,8 +6678,14 @@ abstract class CommonObject
require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php';
$comment = new Comment($this->db);
$this->comments = Comment::fetchAllFor($this->element, $this->id);
return 1;
$result=$comment->fetchAllFor($this->element, $this->id);
if ($result<0) {
$this->errors=array_merge($this->errors,$comment->errors);
return -1;
} else {
$this->comments = $comment->comments;
}
return count($this->comments);
}
/**

View File

@ -3100,7 +3100,7 @@ class Form
* @param string $morecss Add more CSS on select tag
* @return void
*/
function select_types_paiements($selected='', $htmlname='paiementtype', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $active=1, $morecss='')
function select_types_paiements($selected='', $htmlname='paiementtype', $filtertype='', $format=0, $empty=1, $noadmininfo=0, $maxlength=0, $active=1, $morecss='')
{
global $langs,$user;

View File

@ -545,9 +545,10 @@ class FormCompany
* @param array $limitto Disable answers that are not id in this array list
* @param int $forceid This is to force another object id than object->id
* @param string $moreparam String with more param to add into url when noajax search is used.
* @param string $morecss More CSS on select component
* @return int The selected third party ID
*/
function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='')
function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='', $morecss='')
{
global $conf, $langs;
@ -649,7 +650,7 @@ class FormCompany
$resql = $this->db->query($sql);
if ($resql)
{
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"';
print '<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'"';
if ($conf->use_javascript_ajax)
{
$javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";

View File

@ -863,11 +863,12 @@ class FormOther
* @param int $offset Offset
* @param int $invert Invert
* @param string $option Option
* @param string $morecss More CSS
* @return string
*/
function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='')
function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='', $morecss='')
{
print $this->selectyear($selected,$htmlname,$useempty,$min_year,$max_year,$offset,$invert,$option);
print $this->selectyear($selected,$htmlname,$useempty,$min_year,$max_year,$offset,$invert,$option,$morecss);
}
/**

View File

@ -175,14 +175,21 @@ function societe_prepare_head(Societe $object)
$h++;
}
// Bank accounrs
// Bank accounts
if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT))
{
$langs->load("banks");
$langs->load("banks");
$title = $langs->trans("BankAccounts");
if (! empty($conf->stripe->enabled))
{
$langs->load("stripe");
$title = $langs->trans("BankAccountsAndGateways");
}
$nbBankAccount=0;
$head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$object->id;
$head[$h][1] = $langs->trans("BankAccounts");
$head[$h][0] = DOL_URL_ROOT .'/societe/paymentmodes.php?socid='.$object->id;
$head[$h][1] = $title;
$sql = "SELECT COUNT(n.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib as n";
$sql.= " WHERE fk_soc = ".$object->id;
@ -1707,3 +1714,5 @@ function show_subsidiaries($conf,$langs,$db,$object)
return $i;
}

View File

@ -1077,11 +1077,12 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
* @param string $picto Add a picto on tab title
* @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto.
* @param string $morehtmlright Add more html content on right of tabs title
* @param string $morecss More Css
* @return void
*/
function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
{
print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright);
print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss);
}
/**
@ -1094,9 +1095,10 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto
* @param string $picto Add a picto on tab title
* @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto.
* @param string $morehtmlright Add more html content on right of tabs title
* @param string $morecss More Css
* @return string
*/
function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
{
global $conf, $langs, $hookmanager;
@ -1161,7 +1163,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
{
if (!empty($links[$i][0]))
{
$out.='<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
$out.='<a class="tabimage'.($morecss?' '.$morecss:'').'" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
}
else
{
@ -1173,13 +1175,13 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
//print "x $i $active ".$links[$i][2]." z";
if ($isactive)
{
$out.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabactive tab inline-block" href="'.$links[$i][0].'">';
$out.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabactive tab inline-block'.($morecss?' '.$morecss:'').'" href="'.$links[$i][0].'">';
$out.=$links[$i][1];
$out.='</a>'."\n";
}
else
{
$out.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabunactive tab inline-block" href="'.$links[$i][0].'">';
$out.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabunactive tab inline-block'.($morecss?' '.$morecss:'').'" href="'.$links[$i][0].'">';
$out.=$links[$i][1];
$out.='</a>'."\n";
}
@ -1198,14 +1200,14 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
if (isset($links[$i][2]) && $links[$i][2] == 'image')
{
if (!empty($links[$i][0]))
$outmore.='<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
$outmore.='<a class="tabimage'.($morecss?' '.$morecss:'').'" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
else
$outmore.='<span class="tabspan">'.$links[$i][1].'</span>'."\n";
}
else if (! empty($links[$i][1]))
{
$outmore.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="wordwrap inline-block" href="'.$links[$i][0].'">';
$outmore.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="wordwrap inline-block'.($morecss?' '.$morecss:'').'" href="'.$links[$i][0].'">';
$outmore.=preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts.
$outmore.='</a>'."\n";
}
@ -1489,6 +1491,14 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if ($object->frequency == 0) $morehtmlstatus.=$object->getLibStatut(2);
else $morehtmlstatus.=$object->getLibStatut(5);
}
elseif ($object->element == 'project_task')
{
$object->fk_statut = 1;
if ($object->progress > 0) $object->fk_statut = 2;
if ($object->progress >= 100) $object->fk_statut = 3;
$tmptxt=$object->getLibStatut(5);
$morehtmlstatus.=$tmptxt; // No status on task
}
else { // Generic case
$tmptxt=$object->getLibStatut(6);
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5);
@ -6986,6 +6996,8 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
$i3 = 0;
foreach($tmpcrits as $tmpcrit)
{
if(empty($tmpcrit)) continue;
$newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
if (preg_match('/\.(id|rowid)$/', $field)) // Special case for rowid that is sometimes a ref so used as a search field

View File

@ -71,7 +71,7 @@ class modCommande extends DolibarrModules
$this->depends = array("modSociete");
$this->requiredby = array("modExpedition");
$this->conflictwith = array();
$this->langfiles = array('orders', 'bills', 'companies','products', 'deliveries');
$this->langfiles = array('orders', 'bills', 'companies','products', 'deliveries', 'sendings');
// Constants
$this->const = array();
@ -190,9 +190,9 @@ class modCommande extends DolibarrModules
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='CustomersOrdersAndOrdersLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r]=array(array("commande","commande","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country','co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate','c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','pj.ref'=>'ProjectRef','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct','cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country','co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate",'c.date_livraison'=>"DateDeliveryPlanned",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate','c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','pj.ref'=>'ProjectRef','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct','cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel');
//$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text');
$this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.date_livraison'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company','co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order",'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order",'c.date_livraison'=>"order",'pj.ref'=>'project','cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line",'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line",'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product');
$this->export_dependencies_array[$r]=array('order_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
$keyforselect='commande'; $keyforelement='order'; $keyforaliasextra='extra';

View File

@ -72,7 +72,7 @@ class modFournisseur extends DolibarrModules
// Dependencies
$this->depends = array("modSociete");
$this->requiredby = array();
$this->langfiles = array('bills', 'companies', 'suppliers', 'orders');
$this->langfiles = array('bills', 'companies', 'suppliers', 'orders', 'sendings');
// Config pages
$this->config_page_url = array("supplier_order.php");
@ -453,14 +453,14 @@ class modFournisseur extends DolibarrModules
$this->export_label[$r]='Commandes fournisseurs et lignes de commandes';
$this->export_icon[$r]='order';
$this->export_permission[$r]=array(array("fournisseur","commande","export"));
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.date_approve'=>'DateApprove','f.date_approve2'=>'DateApprove2','f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'ua1.login'=>'ApprovedBy','ua2.login'=>'ApprovedBy2','fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId',
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.date_livraison'=>"DateDeliveryPlanned",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.date_approve'=>'DateApprove','f.date_approve2'=>'DateApprove2','f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'ua1.login'=>'ApprovedBy','ua2.login'=>'ApprovedBy2','fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId',
'p.ref'=>'ProductRef','p.label'=>'ProductLabel','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel');
if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
{
unset($this->export_fields_array['f.date_approve2']);
unset($this->export_fields_array['ua2.login']);
}
$this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.fk_statut'=>'Status','f.date_approve'=>'Date','f.date_approve2'=>'Date','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.remise_percent'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label',
$this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.date_livraison'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.fk_statut'=>'Status','f.date_approve'=>'Date','f.date_approve2'=>'Date','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.remise_percent'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label',
'p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text');
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','ua1.login'=>'user','ua2.login'=>'user','fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product',
'p.ref'=>'product','p.label'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project');

View File

@ -59,7 +59,7 @@ class modMultiCurrency extends DolibarrModules
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Module to enter elements with a foreign currency";
$this->description = "Module to manage several foreign currencies in prices and documents";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'dolibarr';

View File

@ -71,7 +71,7 @@ class modStripe extends DolibarrModules
// Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(5,3); // Minimum version of PHP required by module
$this->phpmin = array(5,4); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(5,0); // Minimum version of Dolibarr required by module
$this->langfiles = array("stripe");
@ -107,6 +107,49 @@ class modStripe extends DolibarrModules
); // 0=Menu for internal users, 1=external users, 2=both
$r++;
$this->menu[$r] = array(
'fk_menu'=>'fk_mainmenu=bank',
'type'=>'left',
'titre'=>'StripeAccount',
'mainmenu'=>'bank',
'leftmenu'=>'stripe',
'url' => '/stripe/charge.php',
'langs' => 'stripe',
'position' => 100,
'enabled' => '$conf->global->MAIN_FEATURES_LEVEL >= 2',
'perms' => '$user->rights->banque->configurer',
'target' => '',
'user' => 0
);
$r++;
$this->menu[$r] = array(
'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
'type' => 'left',
'titre' => 'StripeChargeList',
'url' => '/stripe/charge.php',
'langs' => 'stripe',
'position' => 102,
'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2',
'perms' => '$user->rights->banque->configurer',
'target' => '',
'user' => 0
);
$r++;
$this->menu[$r] = array(
'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe',
'type' => 'left',
'titre' => 'StripeTransactionList',
'url' => '/stripe/transaction.php',
'langs' => 'stripe',
'position' => 102,
'enabled' => '$conf->stripe->enabled && $conf->banque->enabled && $conf->global->MAIN_FEATURES_LEVEL >= 2',
'perms' => '$user->rights->banque->configurer',
'target' => '',
'user' => 0
);
// Exports
$r=1;
}

View File

@ -43,7 +43,7 @@ print '<td colspan="3">';
$desc = GETPOST('comment_description');
$doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '100%');
$doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%');
print $doleditor->Create(1);
print '</td>';

View File

@ -91,7 +91,7 @@ if ($permission) {
<?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
<div class="nowrap tagtd"><?php echo img_object('','user').' '.$langs->trans("Users"); ?></div>
<div class="tagtd"><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></div>
<div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56); ?></div>
<div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?></div>
<div class="tagtd maxwidthonsmartphone">
<?php
$tmpobject=$object;
@ -126,16 +126,16 @@ if ($permission) {
echo img_object('', 'company', 'class="hideonsmartphone"');
}
?>
<?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0); ?>
<?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, '', 'minwidth300imp'); ?>
</div>
<div class="tagtd maxwidthonsmartphone noborderbottom">
<?php $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid', 0, '', '', 0, 'minwidth200'); ?>
<?php $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid', 0, '', '', 0, 'minwidth100imp'); ?>
</div>
<div class="tagtd maxwidthonsmartphone noborderbottom">
<?php
$tmpobject=$object;
if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
$formcompany->selectTypeContact($tmpobject, '', 'type','external'); ?>
$formcompany->selectTypeContact($tmpobject, '', 'type','external', 'position', 0, 'minwidth100imp'); ?>
</div>
<div class="tagtd noborderbottom">&nbsp;</div>
<div class="tagtd center noborderbottom">

View File

@ -655,20 +655,53 @@ class InterfaceActionsAuto extends DolibarrTriggers
$object->sendtoid=0;
}
elseif ($action == 'MEMBER_SUBSCRIPTION')
elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE')
{
$langs->load("agenda");
$langs->load("other");
$langs->load("members");
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->getFullName($langs));
$object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->getFullName($langs));
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
$object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
$object->sendtoid=0;
if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
}
elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY')
{
$langs->load("agenda");
$langs->load("other");
$langs->load("members");
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
$object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
$object->sendtoid=0;
if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
}
elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE')
{
$langs->load("agenda");
$langs->load("other");
$langs->load("members");
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
$object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
$object->sendtoid=0;
if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
}
elseif ($action == 'MEMBER_RESILIATE')
{
@ -816,6 +849,14 @@ class InterfaceActionsAuto extends DolibarrTriggers
$projectid = isset($object->fk_project)?$object->fk_project:0;
if ($object->element == 'project') $projectid = $object->id;
$elementid = $object->id;
$elementtype = $object->element;
if ($object->element == 'subscription')
{
$elementid = $object->fk_adherent;
$elementtype = 'member';
}
// Insertion action
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$actioncomm = new ActionComm($this->db);
@ -845,8 +886,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
$actioncomm->email_subject = $object->email_subject;
$actioncomm->errors_to = $object->errors_to;
$actioncomm->fk_element = $object->id;
$actioncomm->elementtype = $object->element;
$actioncomm->fk_element = $elementid;
$actioncomm->elementtype = $elementtype;
$ret=$actioncomm->create($user); // User creating action

View File

@ -1535,13 +1535,17 @@ class CommandeFournisseur extends CommonOrder
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
if ($conf->multicurrency->enabled && $pu_ht_devise > 0) {
$pu = 0;
}
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx,$pu_ht_devise);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
$pu_ht = $tabprice[3];
$pu = $pu_ht = $tabprice[3];
// MultiCurrency
$multicurrency_total_ht = $tabprice[16];

View File

@ -1387,7 +1387,7 @@ class FactureFournisseur extends CommonInvoice
{
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
global $mysoc;
global $mysoc, $conf;
// Clean parameters
if (empty($remise_percent)) $remise_percent=0;
@ -1416,6 +1416,10 @@ class FactureFournisseur extends CommonInvoice
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
if ($conf->multicurrency->enabled && $pu_ht_devise > 0) {
$pu = 0;
}
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];

View File

@ -69,6 +69,13 @@ class ProductFournisseur extends Product
var $supplier_reputation; // reputation of supplier
var $reputations=array(); // list of available supplier reputations
// Multicurreny
var $fourn_multicurrency_id;
var $fourn_multicurrency_code;
var $fourn_multicurrency_tx;
var $fourn_multicurrency_price;
var $fourn_multicurrency_unitprice;
/**
* Constructor
*
@ -169,25 +176,29 @@ class ProductFournisseur extends Product
/**
* Modify the purchase price for a supplier
*
* @param int $qty Min quantity for which price is valid
* @param float $buyprice Purchase price for the quantity min
* @param User $user Object user user made changes
* @param string $price_base_type HT or TTC
* @param Societe $fourn Supplier
* @param int $availability Product availability
* @param string $ref_fourn Supplier ref
* @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string)
* @param string $charges costs affering to product
* @param float $remise_percent Discount regarding qty (percent)
* @param float $remise Discount regarding qty (amount)
* @param int $newnpr Set NPR or not
* @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined.
* @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER)
* @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
* @param string $newdefaultvatcode Default vat code
* @param int $qty Min quantity for which price is valid
* @param float $buyprice Purchase price for the quantity min
* @param User $user Object user user made changes
* @param string $price_base_type HT or TTC
* @param Societe $fourn Supplier
* @param int $availability Product availability
* @param string $ref_fourn Supplier ref
* @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string)
* @param string $charges costs affering to product
* @param float $remise_percent Discount regarding qty (percent)
* @param float $remise Discount regarding qty (amount)
* @param int $newnpr Set NPR or not
* @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined.
* @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER)
* @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
* @param string $newdefaultvatcode Default vat code
* @param float $multicurrency_buyprice Purchase price for the quantity min in currency
* @param string $multicurrency_price_base_type HT or TTC in currency
* @param float $multicurrency_tx Rate currency
* @param string $multicurrency_code Currency code
* @return int <0 if KO, >=0 if OK
*/
function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0, $delivery_time_days=0, $supplier_reputation='', $localtaxes_array=array(), $newdefaultvatcode='')
function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges=0, $remise_percent=0, $remise=0, $newnpr=0, $delivery_time_days=0, $supplier_reputation='', $localtaxes_array=array(), $newdefaultvatcode='', $multicurrency_buyprice=0, $multicurrency_price_base_type='HT',$multicurrency_tx=1,$multicurrency_code='')
{
global $conf, $langs;
//global $mysoc;
@ -205,6 +216,25 @@ class ProductFournisseur extends Product
$ttx = $tva_tx;
$buyprice = $buyprice/(1+($ttx/100));
}
// Multicurrency
if ($conf->multicurrency->enabled) {
if (empty($multicurrency_tx)) $multicurrency_tx=1;
if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0;
if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0;
if ($multicurrency_price_base_type == 'TTC')
{
$ttx = $tva_tx;
$multicurrency_buyprice = $multicurrency_buyprice/(1+($ttx/100));
}
$multicurrency_buyprice=price2num($multicurrency_buyprice,'MU');
$multicurrency_unitBuyPrice=price2num($multicurrency_buyprice/$qty,'MU');
$buyprice=$multicurrency_buyprice/$multicurrency_tx;
$fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code);
}
$buyprice=price2num($buyprice,'MU');
$charges=price2num($charges,'MU');
$qty=price2num($qty);
@ -246,6 +276,11 @@ class ProductFournisseur extends Product
$sql.= " remise = ".$remise.",";
$sql.= " unitprice = ".$unitBuyPrice.",";
$sql.= " fk_availability = ".$availability.",";
$sql.= " multicurrency_price = ".(isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').",";
$sql.= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').",";
$sql.= " multicurrency_tx = ".(isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').",";
$sql.= " fk_multicurrency = ".(isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').",";
$sql.= " multicurrency_code = ".(isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').",";
$sql.= " entity = ".$conf->entity.",";
$sql.= " tva_tx = ".price2num($tva_tx).",";
// TODO Add localtax1 and localtax2
@ -300,8 +335,15 @@ class ProductFournisseur extends Product
if ($resql) {
// Add price for this quantity to supplier
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price(";
$sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
$sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)";
$sql .= " values('" . $this->db->idate($now) . "',";
$sql .= " values(";
$sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').",";
$sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').",";
$sql.= (isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').",";
$sql.= (isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').",";
$sql.= (isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').",";
$sql .= " '" . $this->db->idate($now) . "',";
$sql .= " " . $this->id . ",";
$sql .= " " . $fourn->id . ",";
$sql .= " '" . $this->db->escape($ref_fourn) . "',";
@ -334,8 +376,15 @@ class ProductFournisseur extends Product
if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) {
// Add record into log table
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_log(";
$sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
$sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)";
$sql .= "values('" . $this->db->idate($now) . "',";
$sql .= "values(";
$sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').",";
$sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').",";
$sql.= (isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').",";
$sql.= (isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').",";
$sql.= (isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').",";
$sql .= " '" . $this->db->idate($now) . "',";
$sql .= " " . $this->product_fourn_id . ",";
$sql .= " " . $user->id . ",";
$sql .= " " . price2num($buyprice) . ",";
@ -388,6 +437,7 @@ class ProductFournisseur extends Product
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.fk_availability,";
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price
$sql.= " pfp.supplier_reputation";
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.rowid = ".$rowid;
@ -421,6 +471,12 @@ class ProductFournisseur extends Product
$this->supplier_reputation = $obj->supplier_reputation;
$this->default_vat_code = $obj->default_vat_code;
$this->fourn_multicurrency_price = $obj->multicurrency_price;
$this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice;
$this->fourn_multicurrency_tx = $obj->multicurrency_tx;
$this->fourn_multicurrency_id = $obj->fk_multicurrency;
$this->fourn_multicurrency_code = $obj->multicurrency_code;
if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression))
{
$priceparser = new PriceParser($this->db);
@ -471,6 +527,7 @@ class ProductFournisseur extends Product
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
$sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation";
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE pfp.entity IN (".getEntity('productprice').")";
@ -512,6 +569,12 @@ class ProductFournisseur extends Product
$prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
$prodfourn->supplier_reputation = $record["supplier_reputation"];
$prodfourn->fourn_multicurrency_price = $record["multicurrency_price"];
$prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"];
$prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"];
$prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"];
$prodfourn->fourn_multicurrency_code = $record["multicurrency_code"];
if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) {
$priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProductSupplier($prodfourn);
@ -577,10 +640,17 @@ class ProductFournisseur extends Product
$this->delivery_time_days = '';
$this->id = '';
$this->fourn_multicurrency_price = '';
$this->fourn_multicurrency_unitprice = '';
$this->fourn_multicurrency_tx = '';
$this->fourn_multicurrency_id = '';
$this->fourn_multicurrency_code = '';
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
$sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,";
$sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days";
$sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE s.entity IN (".getEntity('societe').")";
$sql.= " AND pfp.fk_product = ".$prodid;
@ -654,6 +724,11 @@ class ProductFournisseur extends Product
$this->delivery_time_days = $record["delivery_time_days"];
$this->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
$this->id = $prodid;
$this->fourn_multicurrency_price = $record["multicurrency_price"];
$this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"];
$this->fourn_multicurrency_tx = $record["multicurrency_tx"];
$this->fourn_multicurrency_id = $record["fk_multicurrency"];
$this->fourn_multicurrency_code = $record["multicurrency_code"];
$min = $fourn_unitprice;
}
}

View File

@ -419,7 +419,8 @@ if (empty($reshook))
$date_start,
$date_end,
$array_options,
$productsupplier->fk_unit
$productsupplier->fk_unit,
$productsupplier->fourn_multicurrency_unitprice
);
}
if ($idprod == -99 || $idprod == 0)

View File

@ -1018,7 +1018,9 @@ if (empty($reshook))
0,
$array_options,
$productsupplier->fk_unit,
$productsupplier->fourn_ref
0,
$productsupplier->fourn_multicurrency_unitprice,
$productsupplier->fourn_ref
);
}
if ($idprod == -99 || $idprod == 0)

View File

@ -655,7 +655,7 @@ if ($resql)
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
{
print '<td class="liste_titre" align="left">';
$form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1, 10);
$form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10);
print '</td>';
}
if (! empty($arrayfields['f.total_ht']['checked']))

View File

@ -12,3 +12,6 @@ composer.lock
# Ignore PHPUnit coverage file
clover.xml
# Ignore IDE's configuration files
.idea

View File

@ -1,18 +1,40 @@
sudo: false
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm
env:
- AUTOLOAD=1
- AUTOLOAD=0
global:
- STRIPE_MOCK_VERSION=0.8.0
matrix:
- AUTOLOAD=1
- AUTOLOAD=0
cache:
directories:
- $HOME/.composer/cache/files
- stripe-mock
before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
- |
if [ ! -d "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}" ]; then
mkdir -p stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/
curl -L "https://github.com/stripe/stripe-mock/releases/download/v${STRIPE_MOCK_VERSION}/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz" -o "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz"
tar -zxf "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz" -C "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/"
fi
- |
stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/stripe-mock > /dev/null &
STRIPE_MOCK_PID=$!
script: ./build.php ${AUTOLOAD}
after_script: ./vendor/bin/coveralls -v
sudo: false

View File

@ -1,237 +1,315 @@
### 4.7.0 2017-04-10
# Changelog
## 6.4.1 - 2018-03-02
* [#455](https://github.com/stripe/stripe-php/pull/455) Fix namespaces in PHPDoc
* [#456](https://github.com/stripe/stripe-php/pull/456) Fix namespaces for some exceptions
## 6.4.0 - 2018-02-28
* [#453](https://github.com/stripe/stripe-php/pull/453) Add constants for `reason` (`REASON_*`) and `status` (`STATUS_*`) on `\Stripe\Dispute`
## 6.3.2 - 2018-02-27
* [#452](https://github.com/stripe/stripe-php/pull/452) Add PHPDoc for `amount_paid` and `amount_remaining` on `\Stripe\Invoice`
## 6.3.1 - 2018-02-26
* [#443](https://github.com/stripe/stripe-php/pull/443) Add event types as constants to `\Stripe\Event` class
## 6.3.0 - 2018-02-23
* [#450](https://github.com/stripe/stripe-php/pull/450) Add support for `code` attribute on all Stripe exceptions
## 6.2.0 - 2018-02-21
* [#440](https://github.com/stripe/stripe-php/pull/440) Add support for topups
* [#442](https://github.com/stripe/stripe-php/pull/442) Fix PHPDoc for `\Stripe\Error\SignatureVerification`
## 6.1.0 - 2018-02-12
* [#435](https://github.com/stripe/stripe-php/pull/435) Fix header persistence on `Collection` objects
* [#436](https://github.com/stripe/stripe-php/pull/436) Introduce new `Idempotency` error class
## 6.0.0 - 2018-02-07
Major version release. List of backwards incompatible changes to watch out for:
+ The minimum PHP version is now 5.4.0. If you're using PHP 5.3 or older, consider upgrading to a more recent version.
* `\Stripe\AttachedObject` no longer exists. Attributes that used to be instances of `\Stripe\AttachedObject` (such as `metadata`) are now instances of `\Stripe\StripeObject`.
+ Attributes that used to be PHP arrays (such as `legal_entity->additional_owners` on `\Stripe\Account` instances) are now instances of `\Stripe\StripeObject`, except when they are empty. `\Stripe\StripeObject` has array semantics so this should not be an issue unless you are actively checking types.
* `\Stripe\Collection` now derives from `\Stripe\StripeObject` rather than from `\Stripe\ApiResource`.
Pull requests included in this release:
* [#410](https://github.com/stripe/stripe-php/pull/410) Drop support for PHP 5.3
* [#411](https://github.com/stripe/stripe-php/pull/411) Use traits for common API operations
* [#414](https://github.com/stripe/stripe-php/pull/414) Use short array syntax
* [#404](https://github.com/stripe/stripe-php/pull/404) Fix serialization logic
* [#417](https://github.com/stripe/stripe-php/pull/417) Remove `ExternalAccount` class
* [#418](https://github.com/stripe/stripe-php/pull/418) Increase test coverage
* [#421](https://github.com/stripe/stripe-php/pull/421) Update CA bundle and add script for future updates
* [#422](https://github.com/stripe/stripe-php/pull/422) Use vendored CA bundle for all requests
* [#428](https://github.com/stripe/stripe-php/pull/428) Support for automatic request retries
## 5.9.2 - 2018-02-07
* [#431](https://github.com/stripe/stripe-php/pull/431) Update PHPDoc @property tags for latest API version
## 5.9.1 - 2018-02-06
* [#427](https://github.com/stripe/stripe-php/pull/427) Add and update PHPDoc @property tags on all API resources
## 5.9.0 - 2018-01-17
* [#421](https://github.com/stripe/stripe-php/pull/421) Updated bundled CA certificates
* [#423](https://github.com/stripe/stripe-php/pull/423) Escape unsanitized input in OAuth example
## 5.8.0 - 2017-12-20
* [#403](https://github.com/stripe/stripe-php/pull/403) Add `__debugInfo()` magic method to `StripeObject`
## 5.7.0 - 2017-11-28
* [#390](https://github.com/stripe/stripe-php/pull/390) Remove some unsupported API methods
* [#391](https://github.com/stripe/stripe-php/pull/391) Alphabetize the list of API resources in `Util::convertToStripeObject()` and add missing resources
* [#393](https://github.com/stripe/stripe-php/pull/393) Fix expiry date update for card sources
## 5.6.0 - 2017-10-31
* [#386](https://github.com/stripe/stripe-php/pull/386) Support for exchange rates APIs
## 5.5.1 - 2017-10-30
* [#387](https://github.com/stripe/stripe-php/pull/387) Allow `personal_address_kana` and `personal_address_kanji` to be updated on an account
## 5.5.0 - 2017-10-27
* [#385](https://github.com/stripe/stripe-php/pull/385) Support for listing source transactions
## 5.4.0 - 2017-10-24
* [#383](https://github.com/stripe/stripe-php/pull/383) Add static methods to manipulate resources from parent
* `Account` gains methods for external accounts and login links (e.g. `createExternalAccount`, `createLoginLink`)
* `ApplicationFee` gains methods for refunds
* `Customer` gains methods for sources
* `Transfer` gains methods for reversals
## 5.3.0 - 2017-10-11
* [#378](https://github.com/stripe/stripe-php/pull/378) Rename source `delete` to `detach` (and deprecate the former)
## 5.2.3 - 2017-09-27
* Add PHPDoc for `Card`
## 5.2.2 - 2017-09-20
* Fix deserialization mapping of `FileUpload` objects
## 5.2.1 - 2017-09-14
* Serialized `shipping` nested attribute
## 5.2.0 - 2017-08-29
* Add support for `InvalidClient` OAuth error
## 5.1.3 - 2017-08-14
* Allow `address_kana` and `address_kanji` to be updated for custom accounts
## 5.1.2 - 2017-08-01
* Fix documented return type of `autoPagingIterator()` (was missing namespace)
## 5.1.1 - 2017-07-03
* Fix order returns to use the right URL `/v1/order_returns`
## 5.1.0 - 2017-06-30
* Add support for OAuth
## 5.0.0 - 2017-06-27
* `pay` on invoice now takes params as well as opts
## 4.13.0 - 2017-06-19
* Add support for ephemeral keys
## 4.12.0 - 2017-06-05
* Clients can implement `getUserAgentInfo()` to add additional user agent information
## 4.11.0 - 2017-06-05
* Implement `Countable` for `AttachedObject` (`metadata` and `additional_owners`)
## 4.10.0 - 2017-05-25
* Add support for login links
## 4.9.1 - 2017-05-10
* Fix docs to include arrays on `$id` parameter for retrieve methods
## 4.9.0 - 2017-04-28
* Support for checking webhook signatures
## 4.8.1 - 2017-04-24
* Allow nested field `payout_schedule` to be updated
## 4.8.0 - 2017-04-20
* Add `\Stripe\Stripe::setLogger()` to support an external PSR-3 compatible logger
## 4.7.0 - 2017-04-10
* Add support for payouts and recipient transfers
### 4.6.0 2017-04-06
## 4.6.0 - 2017-04-06
* Please see 4.7.0 instead (no-op release)
### 4.5.1 2017-03-22
## 4.5.1 - 2017-03-22
* Remove hard dependency on cURL
### 4.5.0 2017-03-20
## 4.5.0 - 2017-03-20
* Support for detaching sources from customers
### 4.4.2 2017-02-27
## 4.4.2 - 2017-02-27
* Correct handling of `owner` parameter when updating sources
### 4.4.1 2017-02-24
## 4.4.1 - 2017-02-24
* Correct the error check on a bad JSON decoding
### 4.4.0 2017-01-18
## 4.4.0 - 2017-01-18
* Add support for updating sources
### 4.3.0 2016-11-30
## 4.3.0 - 2016-11-30
* Add support for verifying sources
### 4.2.0 2016-11-21
## 4.2.0 - 2016-11-21
* Add retrieve method for 3-D Secure resources
### 4.1.1 2016-10-21
## 4.1.1 - 2016-10-21
* Add docblock with model properties for `Plan`
### 4.1.0 2016-10-18
## 4.1.0 - 2016-10-18
* Support for 403 status codes (permission denied)
### 4.0.1 2016-10-17
## 4.0.1 - 2016-10-17
* Fix transfer reversal materialization
* Fixes for some property definitions in docblocks
### 4.0.0 2016-09-28
## 4.0.0 - 2016-09-28
* Support for subscription items
* Drop attempt to force TLS 1.2: please note that this could be breaking if you're using old OS distributions or packages and upgraded recently (so please make sure to test your integration!)
### 3.23.0 2016-09-15
## 3.23.0 - 2016-09-15
* Add support for Apple Pay domains
### 3.22.0 2016-09-13
## 3.22.0 - 2016-09-13
* Add `Stripe::setAppInfo` to allow plugins to register user agent information
### 3.21.0 2016-08-25
## 3.21.0 - 2016-08-25
* Add `Source` model for generic payment sources
### 3.20.0 2016-08-08
## 3.20.0 - 2016-08-08
* Add `getDeclineCode` to card errors
### 3.19.0 2016-07-29
## 3.19.0 - 2016-07-29
* Opt requests directly into TLS 1.2 where OpenSSL >= 1.0.1 (see #277 for context)
### 3.18.0 2016-07-28
## 3.18.0 - 2016-07-28
* Add new `STATUS_` constants for subscriptions
### 3.17.1 2016-07-28
## 3.17.1 - 2016-07-28
* Fix auto-paging iterator so that it plays nicely with `iterator_to_array`
### 3.17.0 2016-07-14
## 3.17.0 - 2016-07-14
* Add field annotations to model classes for better editor hinting
### 3.16.0 2016-07-12
## 3.16.0 - 2016-07-12
* Add `ThreeDSecure` model for 3-D secure payments
### 3.15.0 2016-06-29
## 3.15.0 - 2016-06-29
* Add static `update` method to all resources that can be changed.
### 3.14.3 2016-06-20
## 3.14.3 - 2016-06-20
* Make sure that cURL never sends `Expects: 100-continue`, even on large request bodies
### 3.14.2 2016-06-03
## 3.14.2 - 2016-06-03
* Add `inventory` under `SKU` to list of keys that have nested data and can be updated
### 3.14.1 2016-05-27
## 3.14.1 - 2016-05-27
* Fix some inconsistencies in PHPDoc
### 3.14.0 2016-05-25
## 3.14.0 - 2016-05-25
* Add support for returning Relay orders
### 3.13.0 2016-05-04
## 3.13.0 - 2016-05-04
* Add `list`, `create`, `update`, `retrieve`, and `delete` methods to the Subscription class
### 3.12.1 2016-04-07
## 3.12.1 - 2016-04-07
* Additional check on value arrays for some extra safety
### 3.12.0 2016-03-31
## 3.12.0 - 2016-03-31
* Fix bug `refreshFrom` on `StripeObject` would not take an `$opts` array
* Fix bug where `$opts` not passed to parent `save` method in `Account`
* Fix bug where non-existent variable was referenced in `reverse` in `Transfer`
* Update CA cert bundle for compatibility with OpenSSL versions below 1.0.1
### 3.11.0 2016-03-22
## 3.11.0 - 2016-03-22
* Allow `CurlClient` to be initialized with default `CURLOPT_*` options
### 3.10.1 2016-03-22
## 3.10.1 - 2016-03-22
* Fix bug where request params and options were ignored in `ApplicationFee`'s `refund.`
### 3.10.0 2016-03-15
## 3.10.0 - 2016-03-15
* Add `reject` on `Account` to support the new API feature
### 3.9.2 2016-03-04
## 3.9.2 - 2016-03-04
* Fix error when an object's metadata is set more than once
### 3.9.1 2016-02-24
## 3.9.1 - 2016-02-24
* Fix encoding behavior of nested arrays for requests (see #227)
### 3.9.0 2016-02-09
## 3.9.0 - 2016-02-09
* Add automatic pagination mechanism with `autoPagingIterator()`
* Allow global account ID to be set with `Stripe::setAccountId()`
### 3.8.0 2016-02-08
## 3.8.0 - 2016-02-08
* Add `CountrySpec` model for looking up country payment information
### 3.7.1 2016-02-01
## 3.7.1 - 2016-02-01
* Update bundled CA certs
### 3.7.0 2016-01-27
## 3.7.0 - 2016-01-27
* Support deleting Relay products and SKUs
### 3.6.0 2016-01-05
## 3.6.0 - 2016-01-05
* Allow configuration of HTTP client timeouts
### 3.5.0 2015-12-01
## 3.5.0 - 2015-12-01
* Add a verification routine for external accounts
### 3.4.0 2015-09-14
## 3.4.0 - 2015-09-14
* Products, SKUs, and Orders -- https://stripe.com/relay
### 3.3.0 2015-09-11
## 3.3.0 - 2015-09-11
* Add support for 429 Rate Limit response
### 3.2.0 2015-08-17
## 3.2.0 - 2015-08-17
* Add refund listing and retrieval without an associated charge
### 3.1.0 2015-08-03
## 3.1.0 - 2015-08-03
* Add dispute listing and retrieval
* Add support for manage account deletion
### 3.0.0 2015-07-28
## 3.0.0 - 2015-07-28
* Rename `\Stripe\Object` to `\Stripe\StripeObject` (PHP 7 compatibility)
* Rename `getCode` and `getParam` in exceptions to `getStripeCode` and `getStripeParam`
* Add support for calling `json_encode` on Stripe objects in PHP 5.4+
* Start supporting/testing PHP 7
### 2.3.0 2015-07-06
## 2.3.0 - 2015-07-06
* Add request ID to all Stripe exceptions
### 2.2.0 2015-06-01
## 2.2.0 - 2015-06-01
* Add support for Alipay accounts as sources
* Add support for bank accounts as sources (private beta)
* Add support for bank accounts and cards as external_accounts on Account objects
### 2.1.4 2015-05-13
## 2.1.4 - 2015-05-13
* Fix CA certificate file path (thanks @lphilps & @matthewarkin)
### 2.1.3 2015-05-12
## 2.1.3 - 2015-05-12
* Fix to account updating to permit `tos_acceptance` and `personal_address` to be set properly
* Fix to Transfer reversal creation (thanks @neatness!)
* Network requests are now done through a swappable class for easier mocking
### 2.1.2 2015-04-10
## 2.1.2 - 2015-04-10
* Remove SSL cert revokation checking (all pre-Heartbleed certs have expired)
* Bug fixes to account updating
### 2.1.1 2015-02-27
## 2.1.1 - 2015-02-27
* Support transfer reversals
### 2.1.0 2015-02-19
## 2.1.0 - 2015-02-19
* Support new API version (2015-02-18)
* Added Bitcoin Receiever update and delete actions
* Edited tests to prefer "source" over "card" as per new API version
### 2.0.1 2015-02-16
## 2.0.1 - 2015-02-16
* Fix to fetching endpoints that use a non-default baseUrl (`FileUpload`)
### 2.0.0 2015-02-14
## 2.0.0 - 2015-02-14
* Bumped minimum version to 5.3.3
* Switched to Stripe namespace instead of Stripe_ class name prefiexes (thanks @chadicus!)
* Switched tests to PHPUnit (thanks @chadicus!)
@ -239,192 +317,134 @@
* Added $opts hash to the end of most methods: this permits passing 'idempotency_key', 'stripe_account', or 'stripe_version'. The last 2 will persist across multiple object loads.
* Added support for retrieving Account by ID
### 1.18.0 2015-01-21
## 1.18.0 - 2015-01-21
* Support making bitcoin charges through BitcoinReceiver source object
### 1.17.5 2014-12-23
## 1.17.5 - 2014-12-23
* Adding support for creating file uploads.
### 1.17.4 2014-12-15
## 1.17.4 - 2014-12-15
* Saving objects fetched with a custom key now works (thanks @JustinHook & @jpasilan)
* Added methods for reporting charges as safe or fraudulent and for specifying the reason for refunds
### 1.17.3 2014-11-06
## 1.17.3 - 2014-11-06
* Better handling of HHVM support for SSL certificate blacklist checking.
### 1.17.2 2014-09-23
## 1.17.2 - 2014-09-23
* Coupons now are backed by a `Stripe_Coupon` instead of `Stripe_Object`, and support updating metadata
* Running operations (`create`, `retrieve`, `all`) on upcoming invoice items now works
### 1.17.1 2014-07-31
## 1.17.1 - 2014-07-31
* Requests now send Content-Type header
### 1.17.0 2014-07-29
## 1.17.0 - 2014-07-29
* Application Fee refunds now a list instead of array
* HHVM now works
* Small bug fixes (thanks @bencromwell & @fastest963)
* __toString now returns the name of the object in addition to its JSON representation
### 1.16.0 2014-06-17
* `__toString` now returns the name of the object in addition to its JSON representation
## 1.16.0 - 2014-06-17
* Add metadata for refunds and disputes
### 1.15.0 2014-05-28
## 1.15.0 - 2014-05-28
* Support canceling transfers
### 1.14.1 2014-05-21
## 1.14.1 - 2014-05-21
* Support cards for recipients.
### 1.13.1 2014-05-15
## 1.13.1 - 2014-05-15
* Fix bug in account resource where `id` wasn't in the result
### 1.13.0 2014-04-10
## 1.13.0 - 2014-04-10
* Add support for certificate blacklisting
* Update ca bundle
* Drop support for HHVM (Temporarily)
### 1.12.0 2014-04-01
## 1.12.0 - 2014-04-01
* Add Stripe_RateLimitError for catching rate limit errors.
* Update to Zend coding style (thanks, @jpiasetz)
### 1.11.0 2014-01-29
## 1.11.0 - 2014-01-29
* Add support for multiple subscriptions per customer
### 1.10.1 2013-12-02
## 1.10.1 - 2013-12-02
* Add new ApplicationFee
### 1.9.1 2013-11-08
## 1.9.1 - 2013-11-08
* Fix a bug where a null nestable object causes warnings to fire.
### 1.9.0 2013-10-16
## 1.9.0 - 2013-10-16
* Add support for metadata API.
### 1.8.4 2013-09-18
## 1.8.4 - 2013-09-18
* Add support for closing disputes.
### 1.8.3 2013-08-13
## 1.8.3 - 2013-08-13
* Add new Balance and BalanceTransaction
### 1.8.2 2013-08-12
* Add support for unsetting attributes by updating to NULL.
Setting properties to a blank string is now an error.
### 1.8.1 2013-07-12
## 1.8.2 - 2013-08-12
* Add support for unsetting attributes by updating to NULL. Setting properties to a blank string is now an error.
## 1.8.1 - 2013-07-12
* Add support for multiple cards API (Stripe API version 2013-07-12: https://stripe.com/docs/upgrades#2013-07-05)
### 1.8.0 2013-04-11
## 1.8.0 - 2013-04-11
* Allow Transfers to be creatable
* Add new Recipient resource
### 1.7.15 2013-02-21
## 1.7.15 - 2013-02-21
* Add 'id' to the list of permanent object attributes
### 1.7.14 2013-02-20
## 1.7.14 - 2013-02-20
* Don't re-encode strings that are already encoded in UTF-8. If you
were previously using plan or coupon objects with UTF-8 IDs, they
may have been treated as ISO-8859-1 (Latin-1) and encoded to UTF-8 a
2nd time. You may now need to pass the IDs to utf8_encode before
passing them to Stripe_Plan::retrieve or Stripe_Coupon::retrieve.
* Ensure that all input is encoded in UTF-8 before submitting it to
Stripe's servers. (github issue #27)
* Don't re-encode strings that are already encoded in UTF-8. If you were previously using plan or coupon objects with UTF-8 IDs, they may have been treated as ISO-8859-1 (Latin-1) and encoded to UTF-8 a 2nd time. You may now need to pass the IDs to utf8_encode before passing them to Stripe_Plan::retrieve or Stripe_Coupon::retrieve.
* Ensure that all input is encoded in UTF-8 before submitting it to Stripe's servers. (github issue #27)
### 1.7.13 2013-02-01
* Add support for passing options when retrieving Stripe objects
e.g., Stripe_Charge::retrieve(array("id"=>"foo", "expand" => array("customer")))
Stripe_Charge::retrieve("foo") will continue to work
### 1.7.12 2013-01-15
## 1.7.13 - 2013-02-01
* Add support for passing options when retrieving Stripe objects e.g., Stripe_Charge::retrieve(array("id"=>"foo", "expand" => array("customer"))); Stripe_Charge::retrieve("foo") will continue to work
## 1.7.12 - 2013-01-15
* Add support for setting a Stripe API version override
### 1.7.11 2012-12-30
* Version bump to cleanup constants and such (github issue #26)
### 1.7.10 2012-11-08
## 1.7.11 - 2012-12-30
* Version bump to cleanup constants and such (fix issue #26)
## 1.7.10 - 2012-11-08
* Add support for updating charge disputes.
* Fix bug preventing retrieval of null attributes
### 1.7.9 2012-11-08
## 1.7.9 - 2012-11-08
* Fix usage under autoloaders such as the one generated by composer (fix issue #22)
* Fix usage under autoloaders such as the one generated by composer
(github issue #22)
### 1.7.8 2012-10-30
## 1.7.8 - 2012-10-30
* Add support for creating invoices.
* Add support for new invoice lines return format
* Add support for new list objects
### 1.7.7 2012-09-14
* Get all of the various version numbers in the repo in sync (no other
changes)
### 1.7.6 2012-08-31
## 1.7.7 - 2012-09-14
* Get all of the various version numbers in the repo in sync (no other changes)
## 1.7.6 - 2012-08-31
* Add update and pay methods to Invoice resource
### 1.7.5 2012-08-23
## 1.7.5 - 2012-08-23
* Change internal function names so that Stripe_SingletonApiRequest is E_STRICT-clean (github issue #16)
* Change internal function names so that Stripe_SingletonApiRequest is
E_STRICT-clean (github issue #16)
### 1.7.4 2012-08-21
* Bugfix so that Stripe objects (e.g. Customer, Charge objects) used
in API calls are transparently converted to their object IDs
### 1.7.3 2012-08-15
## 1.7.4 - 2012-08-21
* Bugfix so that Stripe objects (e.g. Customer, Charge objects) used in API calls are transparently converted to their object IDs
## 1.7.3 - 2012-08-15
* Add new Account resource
### 1.7.2 2012-06-26
## 1.7.2 - 2012-06-26
* Make clearer that you should be including lib/Stripe.php, not test/Stripe.php (github issue #14)
* Make clearer that you should be including lib/Stripe.php, not
test/Stripe.php (github issue #14)
### 1.7.1 2012-05-24
* Add missing argument to Stripe_InvalidRequestError constructor in
Stripe_ApiResource::instanceUrl. Fixes a warning when
Stripe_ApiResource::instanceUrl is called on a resource with no ID
(github issue #12)
### 1.7.0 2012-05-17
## 1.7.1 - 2012-05-24
* Add missing argument to Stripe_InvalidRequestError constructor in Stripe_ApiResource::instanceUrl. Fixes a warning when Stripe_ApiResource::instanceUrl is called on a resource with no ID (fix issue #12)
## 1.7.0 - 2012-05-17
* Support Composer and Packagist (github issue #9)
* Add new deleteDiscount method to Stripe_Customer
* Add new Transfer resource
* Switch from using HTTP Basic auth to Bearer auth. (Note: Stripe will
support Basic auth for the indefinite future, but recommends Bearer
auth when possible going forward)
* Switch from using HTTP Basic auth to Bearer auth. (Note: Stripe will support Basic auth for the indefinite future, but recommends Bearer auth when possible going forward)
* Numerous test suite improvements

View File

@ -10,7 +10,7 @@ You can sign up for a Stripe account at https://stripe.com.
## Requirements
PHP 5.3.3 and later.
PHP 5.4.0 and later.
## Composer
@ -20,7 +20,7 @@ You can install the bindings via [Composer](http://getcomposer.org/). Run the fo
composer require stripe/stripe-php
```
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/00-intro.md#autoloading):
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
```php
require_once('vendor/autoload.php');
@ -36,7 +36,7 @@ require_once('/path/to/stripe-php/init.php');
## Dependencies
The bindings require the following extension in order to work properly:
The bindings require the following extensions in order to work properly:
- [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
- [`json`](https://secure.php.net/manual/en/book.json.php)
@ -50,7 +50,7 @@ Simple usage looks like:
```php
\Stripe\Stripe::setApiKey('sk_test_BQokikJOvBiI2HlWgH4olfQ2');
$charge = \Stripe\Charge::create(array('amount' => 2000, 'currency' => 'usd', 'source' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq' ));
$charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq']);
echo $charge;
```
@ -60,14 +60,19 @@ Please see https://stripe.com/docs/api for up-to-date documentation.
## Legacy Version Support
### PHP 5.3
If you are using PHP 5.3, you can download v5.8.0 ([zip](https://github.com/stripe/stripe-php/archive/v5.8.0.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v5.8.0.tar.gz)) from our [releases page](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.
### PHP 5.2
If you are using PHP 5.2, you can download v1.18.0 ([zip](https://github.com/stripe/stripe-php/archive/v1.18.0.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v1.18.0.tar.gz)) from our [releases page](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.
This legacy version may be included via `require_once("/path/to/stripe-php/lib/Stripe.php");`, and used like:
```php
Stripe::setApiKey('d8e8fca2dc0f896fd7cb4cb0031ba249');
$myCard = array('number' => '4242424242424242', 'exp_month' => 8, 'exp_year' => 2018);
$charge = Stripe_Charge::create(array('card' => $myCard, 'amount' => 2000, 'currency' => 'usd'));
$charge = Stripe_Charge::create(array('source' => 'tok_XXXXXXXX', 'amount' => 2000, 'currency' => 'usd'));
echo $charge;
```
@ -98,13 +103,32 @@ Need to set a proxy for your requests? Pass in the requisite `CURLOPT_*` array t
```php
// set up your tweaked Curl client
$curl = new \Stripe\HttpClient\CurlClient(array(CURLOPT_PROXY => 'proxy.local:80'));
$curl = new \Stripe\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']);
// tell Stripe to use the tweaked client
\Stripe\ApiRequestor::setHttpClient($curl);
```
Alternately, a callable can be passed to the CurlClient constructor that returns the above array based on request inputs. See `testDefaultOptions()` in `tests/CurlClientTest.php` for an example of this behavior. Note that the callable is called at the beginning of every API request, before the request is sent.
### Configuring a Logger
The library does minimal logging, but it can be configured
with a [`PSR-3` compatible logger][psr3] so that messages
end up there instead of `error_log`:
```php
\Stripe\Stripe::setLogger($logger);
```
### Accessing response data
You can access the data from the last API response on any object via `getLastResponse()`.
```php
$charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => 'tok_visa']);
echo $charge->getLastResponse()->headers['Request-Id'];
```
### SSL / TLS compatibility issues
Stripe's API now requires that [all connections use TLS 1.2](https://stripe.com/blog/upgrading-tls). Some systems (most notably some older CentOS and RHEL versions) are capable of using TLS 1.2 but will use TLS 1.0 or 1.1 by default. In this case, you'd get an `invalid_request_error` with the following error message: "Stripe no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at [https://stripe.com/blog/upgrading-tls](https://stripe.com/blog/upgrading-tls).".
@ -112,10 +136,49 @@ Stripe's API now requires that [all connections use TLS 1.2](https://stripe.com/
The recommended course of action is to [upgrade your cURL and OpenSSL packages](https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#php) so that TLS 1.2 is used by default, but if that is not possible, you might be able to solve the issue by setting the `CURLOPT_SSLVERSION` option to either `CURL_SSLVERSION_TLSv1` or `CURL_SSLVERSION_TLSv1_2`:
```php
$curl = new \Stripe\HttpClient\CurlClient(array(CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1));
$curl = new \Stripe\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
\Stripe\ApiRequestor::setHttpClient($curl);
```
### Per-request Configuration
For apps that need to use multiple keys during the lifetime of a process, like
one that uses [Stripe Connect][connect], it's also possible to set a
per-request key and/or account:
```php
\Stripe\Charge::all([], [
'api_key' => 'sk_test_...',
'stripe_account' => 'acct_...'
]);
\Stripe\Charge::retrieve("ch_18atAXCdGbJFKhCuBAa4532Z", [
'api_key' => 'sk_test_...',
'stripe_account' => 'acct_...'
]);
```
### Configuring CA Bundles
By default, the library will use its own internal bundle of known CA
certificates, but it's possible to configure your own:
```php
\Stripe\Stripe::setCABundlePath("path/to/ca/bundle");
```
### Configuring Automatic Retries
The library can be configured to automatically retry requests that fail due to
an intermittent network problem:
```php
\Stripe\Stripe::setMaxNetworkRetries(2);
```
[Idempotency keys][idempotency-keys] are added to requests to guarantee that
retries are safe.
## Development
Install dependencies:
@ -124,7 +187,12 @@ Install dependencies:
composer install
```
## Tests
The test suite depends on [stripe-mock], so make sure to fetch and run it from a
background terminal ([stripe-mock's README][stripe-mock] also contains
instructions for installing via Homebrew and other methods):
go get -u github.com/stripe/stripe-mock
stripe-mock
Install dependencies as mentioned above (which will resolve [PHPUnit](http://packagist.org/packages/phpunit/phpunit)), then you can run the test suite:
@ -138,6 +206,12 @@ Or to run an individual test file:
./vendor/bin/phpunit tests/UtilTest.php
```
Update bundled CA certificates from the [Mozilla cURL release][curl]:
```bash
./update_certs.php
```
## Attention plugin developers
Are you writing a plugin that integrates Stripe and embeds our library? Then please use the `setAppInfo` function to identify your plugin. For example:
@ -151,3 +225,9 @@ The method should be called once, before any request is sent to the API. The sec
### SSL / TLS configuration option
See the "SSL / TLS compatibility issues" paragraph above for full context. If you want to ensure that your plugin can be used on all systems, you should add a configuration option to let your users choose between different values for `CURLOPT_SSLVERSION`: none (default), `CURL_SSLVERSION_TLSv1` and `CURL_SSLVERSION_TLSv1_2`.
[connect]: https://stripe.com/connect
[curl]: http://curl.haxx.se/docs/caextract.html
[psr3]: http://www.php-fig.org/psr/psr-3/
[idempotency-keys]: https://stripe.com/docs/api/php#idempotent_requests
[stripe-mock]: https://github.com/stripe/stripe-mock

View File

@ -1 +1 @@
4.7.0
6.4.1

2
htdocs/includes/stripe/build.php Executable file → Normal file
View File

@ -10,7 +10,7 @@ if (!$autoload) {
$composer = json_decode(file_get_contents('composer.json'), true);
unset($composer['autoload']);
unset($composer['require-dev']['squizlabs/php_codesniffer']);
file_put_contents('composer.json', json_encode($composer));
file_put_contents('composer.json', json_encode($composer, JSON_PRETTY_PRINT));
}
passthru('composer install', $returnStatus);

View File

@ -15,7 +15,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.4.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*"

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,9 @@ require(dirname(__FILE__) . '/lib/Stripe.php');
// Utilities
require(dirname(__FILE__) . '/lib/Util/AutoPagingIterator.php');
require(dirname(__FILE__) . '/lib/Util/LoggerInterface.php');
require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php');
require(dirname(__FILE__) . '/lib/Util/RandomGenerator.php');
require(dirname(__FILE__) . '/lib/Util/RequestOptions.php');
require(dirname(__FILE__) . '/lib/Util/Set.php');
require(dirname(__FILE__) . '/lib/Util/Util.php');
@ -19,19 +22,36 @@ require(dirname(__FILE__) . '/lib/Error/Api.php');
require(dirname(__FILE__) . '/lib/Error/ApiConnection.php');
require(dirname(__FILE__) . '/lib/Error/Authentication.php');
require(dirname(__FILE__) . '/lib/Error/Card.php');
require(dirname(__FILE__) . '/lib/Error/Idempotency.php');
require(dirname(__FILE__) . '/lib/Error/InvalidRequest.php');
require(dirname(__FILE__) . '/lib/Error/Permission.php');
require(dirname(__FILE__) . '/lib/Error/RateLimit.php');
require(dirname(__FILE__) . '/lib/Error/SignatureVerification.php');
// OAuth errors
require(dirname(__FILE__) . '/lib/Error/OAuth/OAuthBase.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidClient.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidGrant.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidRequest.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidScope.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedGrantType.php');
require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedResponseType.php');
// API operations
require(dirname(__FILE__) . '/lib/ApiOperations/All.php');
require(dirname(__FILE__) . '/lib/ApiOperations/Create.php');
require(dirname(__FILE__) . '/lib/ApiOperations/Delete.php');
require(dirname(__FILE__) . '/lib/ApiOperations/NestedResource.php');
require(dirname(__FILE__) . '/lib/ApiOperations/Request.php');
require(dirname(__FILE__) . '/lib/ApiOperations/Retrieve.php');
require(dirname(__FILE__) . '/lib/ApiOperations/Update.php');
// Plumbing
require(dirname(__FILE__) . '/lib/ApiResponse.php');
require(dirname(__FILE__) . '/lib/JsonSerializable.php');
require(dirname(__FILE__) . '/lib/StripeObject.php');
require(dirname(__FILE__) . '/lib/ApiRequestor.php');
require(dirname(__FILE__) . '/lib/ApiResource.php');
require(dirname(__FILE__) . '/lib/SingletonApiResource.php');
require(dirname(__FILE__) . '/lib/AttachedObject.php');
require(dirname(__FILE__) . '/lib/ExternalAccount.php');
// Stripe API Resources
require(dirname(__FILE__) . '/lib/Account.php');
@ -51,10 +71,13 @@ require(dirname(__FILE__) . '/lib/CountrySpec.php');
require(dirname(__FILE__) . '/lib/Coupon.php');
require(dirname(__FILE__) . '/lib/Customer.php');
require(dirname(__FILE__) . '/lib/Dispute.php');
require(dirname(__FILE__) . '/lib/EphemeralKey.php');
require(dirname(__FILE__) . '/lib/Event.php');
require(dirname(__FILE__) . '/lib/ExchangeRate.php');
require(dirname(__FILE__) . '/lib/FileUpload.php');
require(dirname(__FILE__) . '/lib/Invoice.php');
require(dirname(__FILE__) . '/lib/InvoiceItem.php');
require(dirname(__FILE__) . '/lib/LoginLink.php');
require(dirname(__FILE__) . '/lib/Order.php');
require(dirname(__FILE__) . '/lib/OrderReturn.php');
require(dirname(__FILE__) . '/lib/Payout.php');
@ -65,9 +88,18 @@ require(dirname(__FILE__) . '/lib/RecipientTransfer.php');
require(dirname(__FILE__) . '/lib/Refund.php');
require(dirname(__FILE__) . '/lib/SKU.php');
require(dirname(__FILE__) . '/lib/Source.php');
require(dirname(__FILE__) . '/lib/SourceTransaction.php');
require(dirname(__FILE__) . '/lib/Subscription.php');
require(dirname(__FILE__) . '/lib/SubscriptionItem.php');
require(dirname(__FILE__) . '/lib/ThreeDSecure.php');
require(dirname(__FILE__) . '/lib/Token.php');
require(dirname(__FILE__) . '/lib/Topup.php');
require(dirname(__FILE__) . '/lib/Transfer.php');
require(dirname(__FILE__) . '/lib/TransferReversal.php');
// OAuth
require(dirname(__FILE__) . '/lib/OAuth.php');
// Webhooks
require(dirname(__FILE__) . '/lib/Webhook.php');
require(dirname(__FILE__) . '/lib/WebhookSignature.php');

View File

@ -7,11 +7,13 @@ namespace Stripe;
*
* @property string $id
* @property string $object
* @property mixed $business_logo
* @property string $business_logo
* @property string $business_name
* @property mixed $business_url
* @property string $business_primary_color
* @property string $business_url
* @property bool $charges_enabled
* @property string $country
* @property int $created
* @property bool $debit_negative_balances
* @property mixed $decline_charge_on
* @property string $default_currency
@ -20,23 +22,46 @@ namespace Stripe;
* @property string $email
* @property mixed $external_accounts
* @property mixed $legal_entity
* @property bool $managed
* @property StripeObject $metadata
* @property mixed $payout_schedule
* @property mixed $payout_statement_descriptor
* @property string $payout_statement_descriptor
* @property bool $payouts_enabled
* @property mixed $product_description
* @property mixed $statement_descriptor
* @property mixed $support_email
* @property mixed $support_phone
* @property string $product_description
* @property string $statement_descriptor
* @property string $support_email
* @property string $support_phone
* @property string $timezone
* @property mixed $tos_acceptance
* @property mixed $verification
* @property mixed $keys
*
* @package Stripe
*/
class Account extends ApiResource
{
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\NestedResource;
use ApiOperations\Retrieve {
retrieve as protected _retrieve;
}
use ApiOperations\Update;
public static function getSavedNestedResources()
{
static $savedNestedResources = null;
if ($savedNestedResources === null) {
$savedNestedResources = new Util\Set([
'external_account',
'bank_account',
]);
}
return $savedNestedResources;
}
const PATH_EXTERNAL_ACCOUNTS = '/external_accounts';
const PATH_LOGIN_LINKS = '/login_links';
public function instanceUrl()
{
if ($this['id'] === null) {
@ -47,7 +72,8 @@ class Account extends ApiResource
}
/**
* @param string|null $id
* @param array|string|null $id The ID of the account to retrieve, or an
* options array containing an `id` key.
* @param array|string|null $opts
*
* @return Account
@ -61,50 +87,6 @@ class Account extends ApiResource
return self::_retrieve($id, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Account
*/
public static function create($params = null, $opts = null)
{
return self::_create($params, $opts);
}
/**
* @param string $id The ID of the account to update.
* @param array|null $params
* @param array|string|null $options
*
* @return Account The updated account.
*/
public static function update($id, $params = null, $options = null)
{
return self::_update($id, $params, $options);
}
/**
* @param array|string|null $opts
*
* @return Account
*/
public function save($opts = null)
{
return $this->_save($opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Account The deleted account.
*/
public function delete($params = null, $opts = null)
{
return $this->_delete($params, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
@ -120,13 +102,133 @@ class Account extends ApiResource
}
/**
* @param array|null $clientId
* @param array|string|null $opts
*
* @return StripeObject Object containing the response from the API.
*/
public function deauthorize($clientId = null, $opts = null)
{
$params = [
'client_id' => $clientId,
'stripe_user_id' => $this->id,
];
OAuth::deauthorize($params, $opts);
}
/**
* @param array|null $id The ID of the account on which to create the external account.
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection of Accounts
* @return BankAccount|Card
*/
public static function all($params = null, $opts = null)
public static function createExternalAccount($id, $params = null, $opts = null)
{
return self::_all($params, $opts);
return self::_createNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
}
/**
* @param array|null $id The ID of the account to which the external account belongs.
* @param array|null $externalAccountId The ID of the external account to retrieve.
* @param array|null $params
* @param array|string|null $opts
*
* @return BankAccount|Card
*/
public static function retrieveExternalAccount($id, $externalAccountId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
}
/**
* @param array|null $id The ID of the account to which the external account belongs.
* @param array|null $externalAccountId The ID of the external account to update.
* @param array|null $params
* @param array|string|null $opts
*
* @return BankAccount|Card
*/
public static function updateExternalAccount($id, $externalAccountId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
}
/**
* @param array|null $id The ID of the account to which the external account belongs.
* @param array|null $externalAccountId The ID of the external account to delete.
* @param array|null $params
* @param array|string|null $opts
*
* @return BankAccount|Card
*/
public static function deleteExternalAccount($id, $externalAccountId, $params = null, $opts = null)
{
return self::_deleteNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
}
/**
* @param array|null $id The ID of the account on which to retrieve the external accounts.
* @param array|null $params
* @param array|string|null $opts
*
* @return BankAccount|Card
*/
public static function allExternalAccounts($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
}
/**
* @param array|null $id The ID of the account on which to create the login link.
* @param array|null $params
* @param array|string|null $opts
*
* @return LoginLink
*/
public static function createLoginLink($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_LOGIN_LINKS, $params, $opts);
}
public function serializeParameters($force = false)
{
$update = parent::serializeParameters($force);
if (isset($this->_values['legal_entity'])) {
$entity = $this['legal_entity'];
if (isset($entity->_values['additional_owners'])) {
$owners = $entity['additional_owners'];
$entityUpdate = isset($update['legal_entity']) ? $update['legal_entity'] : [];
$entityUpdate['additional_owners'] = $this->serializeAdditionalOwners($entity, $owners);
$update['legal_entity'] = $entityUpdate;
}
}
return $update;
}
private function serializeAdditionalOwners($legalEntity, $additionalOwners)
{
if (isset($legalEntity->_originalValues['additional_owners'])) {
$originalValue = $legalEntity->_originalValues['additional_owners'];
} else {
$originalValue = [];
}
if (($originalValue) && (count($originalValue) > count($additionalOwners))) {
throw new \InvalidArgumentException(
"You cannot delete an item from an array, you must instead set a new array"
);
}
$updateArr = [];
foreach ($additionalOwners as $i => $v) {
$update = ($v instanceof StripeObject) ? $v->serializeParameters() : $v;
if ($update !== []) {
if (!$originalValue || ($update != $legalEntity->serializeParamsValue($originalValue[$i], null, false, true))) {
$updateArr[$i] = $update;
}
}
}
return $updateArr;
}
}

View File

@ -6,8 +6,64 @@ namespace Stripe;
* Class AlipayAccount
*
* @package Stripe
*
* @deprecated Alipay accounts are deprecated. Please use the sources API instead.
* @link https://stripe.com/docs/sources/alipay
*/
class AlipayAccount extends ExternalAccount
class AlipayAccount extends ApiResource
{
use ApiOperations\Delete;
use ApiOperations\Update;
/**
* @return string The instance URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern.
*/
public function instanceUrl()
{
if ($this['customer']) {
$base = Customer::classUrl();
$parent = $this['customer'];
$path = 'sources';
} else {
$msg = "Alipay accounts cannot be accessed without a customer ID.";
throw new Error\InvalidRequest($msg, null);
}
$parentExtn = urlencode(Util\Util::utf8($parent));
$extn = urlencode(Util\Util::utf8($this['id']));
return "$base/$parentExtn/$path/$extn";
}
/**
* @param array|string $_id
* @param array|string|null $_opts
*
* @throws \Stripe\Error\InvalidRequest
*
* @deprecated Alipay accounts are deprecated. Please use the sources API instead.
* @link https://stripe.com/docs/sources/alipay
*/
public static function retrieve($_id, $_opts = null)
{
$msg = "Alipay accounts cannot be accessed without a customer ID. " .
"Retrieve an Alipay account using \$customer->sources->retrieve('alipay_account_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
/**
* @param string $_id
* @param array|null $_params
* @param array|string|null $_options
*
* @throws \Stripe\Error\InvalidRequest
*
* @deprecated Alipay accounts are deprecated. Please use the sources API instead.
* @link https://stripe.com/docs/sources/alipay
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = "Alipay accounts cannot be accessed without a customer ID. " .
"Call save() on \$customer->sources->retrieve('alipay_account_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for listable resources. Adds a `all()` static method to the class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait All
{
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return \Stripe\Collection of ApiResources
*/
public static function all($params = null, $opts = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
if (!is_a($obj, 'Stripe\\Collection')) {
$class = get_class($obj);
$message = "Expected type \"Stripe\\Collection\", got \"$class\" instead";
throw new Error\Api($message);
}
$obj->setLastResponse($response);
$obj->setRequestParams($params);
return $obj;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for creatable resources. Adds a `create()` static method to the class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Create
{
/**
* @param array|null $params
* @param array|string|null $options
*
* @return \Stripe\ApiResource The created resource.
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for deletable resources. Adds a `delete()` method to the class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Delete
{
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return \Stripe\ApiResource The deleted resource.
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -0,0 +1,115 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for resources that have nested resources.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait NestedResource
{
/**
* @param string $method
* @param string $url
* @param array|null $params
* @param array|string|null $options
*
* @return \Stripe\StripeObject
*/
protected static function _nestedResourceOperation($method, $url, $params = null, $options = null)
{
self::_validateParams($params);
list($response, $opts) = static::_staticRequest($method, $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param string $id
* @param string $nestedPath
* @param string|null $nestedId
*
* @return string
*/
protected static function _nestedResourceUrl($id, $nestedPath, $nestedId = null)
{
$url = static::resourceUrl($id) . $nestedPath;
if ($nestedId !== null) {
$url .= "/$nestedId";
}
return $url;
}
/**
* @param string $id
* @param string $nestedPath
* @param array|null $params
* @param array|string|null $options
*
* @return \Stripe\StripeObject
*/
protected static function _createNestedResource($id, $nestedPath, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath);
return self::_nestedResourceOperation('post', $url, $params, $options);
}
/**
* @param string $id
* @param string $nestedPath
* @param array|null $params
* @param array|string|null $options
*
* @return \Stripe\StripeObject
*/
protected static function _retrieveNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath, $nestedId);
return self::_nestedResourceOperation('get', $url, $params, $options);
}
/**
* @param string $id
* @param string $nestedPath
* @param array|null $params
* @param array|string|null $options
*
* @return \Stripe\StripeObject
*/
protected static function _updateNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath, $nestedId);
return self::_nestedResourceOperation('post', $url, $params, $options);
}
/**
* @param string $id
* @param string $nestedPath
* @param array|null $params
* @param array|string|null $options
*
* @return \Stripe\StripeObject
*/
protected static function _deleteNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath, $nestedId);
return self::_nestedResourceOperation('delete', $url, $params, $options);
}
/**
* @param string $id
* @param string $nestedPath
* @param array|null $params
* @param array|string|null $options
*
* @return \Stripe\StripeObject
*/
protected static function _allNestedResources($id, $nestedPath, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath);
return self::_nestedResourceOperation('get', $url, $params, $options);
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for resources that need to make API requests.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Request
{
/**
* @param array|null|mixed $params The list of parameters to validate
*
* @throws \Stripe\Error\Api if $params exists and is not an array
*/
protected static function _validateParams($params = null)
{
if ($params && !is_array($params)) {
$message = "You must pass an array as the first argument to Stripe API "
. "method calls. (HINT: an example call to create a charge "
. "would be: \"Stripe\\Charge::create(['amount' => 100, "
. "'currency' => 'usd', 'source' => 'tok_1234'])\")";
throw new \Stripe\Error\Api($message);
}
}
/**
* @param string $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param array $params list of parameters for the request
* @param array|string|null $options
*
* @return array tuple containing (the JSON response, $options)
*/
protected function _request($method, $url, $params = [], $options = null)
{
$opts = $this->_opts->merge($options);
list($resp, $options) = static::_staticRequest($method, $url, $params, $opts);
$this->setLastResponse($resp);
return [$resp->json, $options];
}
/**
* @param string $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param array $params list of parameters for the request
* @param array|string|null $options
*
* @return array tuple containing (the JSON response, $options)
*/
protected static function _staticRequest($method, $url, $params, $options)
{
$opts = \Stripe\Util\RequestOptions::parse($options);
$requestor = new \Stripe\ApiRequestor($opts->apiKey, static::baseUrl());
list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
$opts->discardNonPersistentHeaders();
return [$response, $opts];
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for retrievable resources. Adds a `retrieve()` static method to the
* class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Retrieve
{
/**
* @param array|string $id The ID of the API resource to retrieve,
* or an options array containing an `id` key.
* @param array|string|null $opts
*
* @return \Stripe\StripeObject
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for updatable resources. Adds an `update()` static method and a
* `save()` method to the class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Update
{
/**
* @param string $id The ID of the resource to update.
* @param array|null $params
* @param array|string|null $opts
*
* @return \Stripe\ApiResource The updated resource.
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param array|string|null $opts
*
* @return \Stripe\ApiResource The saved resource.
*/
public function save($opts = null)
{
$params = $this->serializeParameters();
if (count($params) > 0) {
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
}
return $this;
}
}

View File

@ -33,7 +33,7 @@ class ApiRequestor
} elseif ($d === false) {
return 'false';
} elseif (is_array($d)) {
$res = array();
$res = [];
foreach ($d as $k => $v) {
$res[$k] = self::_encodeObjects($v);
}
@ -54,17 +54,13 @@ class ApiRequestor
*/
public function request($method, $url, $params = null, $headers = null)
{
if (!$params) {
$params = array();
}
if (!$headers) {
$headers = array();
}
$params = $params ?: [];
$headers = $headers ?: [];
list($rbody, $rcode, $rheaders, $myApiKey) =
$this->_requestRaw($method, $url, $params, $headers);
$json = $this->_interpretResponse($rbody, $rcode, $rheaders);
$resp = new ApiResponse($rbody, $rcode, $rheaders, $json);
return array($resp, $myApiKey);
return [$resp, $myApiKey];
}
/**
@ -74,6 +70,7 @@ class ApiRequestor
* @param array $resp
*
* @throws Error\InvalidRequest if the error is caused by the user.
* @throws Error\Idempotency if the error is caused by an idempotency key.
* @throws Error\Authentication if the error is caused by a lack of
* permissions.
* @throws Error\Permission if the error is caused by insufficient
@ -84,7 +81,7 @@ class ApiRequestor
* hitting the API.
* @throws Error\Api otherwise.
*/
public function handleApiError($rbody, $rcode, $rheaders, $resp)
public function handleErrorResponse($rbody, $rcode, $rheaders, $resp)
{
if (!is_array($resp) || !isset($resp['error'])) {
$msg = "Invalid response object from API: $rbody "
@ -92,35 +89,75 @@ class ApiRequestor
throw new Error\Api($msg, $rcode, $rbody, $resp, $rheaders);
}
$error = $resp['error'];
$msg = isset($error['message']) ? $error['message'] : null;
$param = isset($error['param']) ? $error['param'] : null;
$code = isset($error['code']) ? $error['code'] : null;
$errorData = $resp['error'];
$error = null;
if (is_string($errorData)) {
$error = self::_specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorData);
}
if (!$error) {
$error = self::_specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData);
}
throw $error;
}
private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData)
{
$msg = isset($errorData['message']) ? $errorData['message'] : null;
$param = isset($errorData['param']) ? $errorData['param'] : null;
$code = isset($errorData['code']) ? $errorData['code'] : null;
$type = isset($errorData['type']) ? $errorData['type'] : null;
switch ($rcode) {
case 400:
// 'rate_limit' code is deprecated, but left here for backwards compatibility
// for API versions earlier than 2015-09-08
if ($code == 'rate_limit') {
throw new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
}
if ($type == 'idempotency_error') {
return new Error\Idempotency($msg, $rcode, $rbody, $resp, $rheaders);
}
// intentional fall-through
case 404:
throw new Error\InvalidRequest($msg, $param, $rcode, $rbody, $resp, $rheaders);
return new Error\InvalidRequest($msg, $param, $rcode, $rbody, $resp, $rheaders);
case 401:
throw new Error\Authentication($msg, $rcode, $rbody, $resp, $rheaders);
return new Error\Authentication($msg, $rcode, $rbody, $resp, $rheaders);
case 402:
throw new Error\Card($msg, $param, $code, $rcode, $rbody, $resp, $rheaders);
return new Error\Card($msg, $param, $code, $rcode, $rbody, $resp, $rheaders);
case 403:
throw new Error\Permission($msg, $rcode, $rbody, $resp, $rheaders);
return new Error\Permission($msg, $rcode, $rbody, $resp, $rheaders);
case 429:
throw new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
default:
throw new Error\Api($msg, $rcode, $rbody, $resp, $rheaders);
return new Error\Api($msg, $rcode, $rbody, $resp, $rheaders);
}
}
private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorCode)
{
$description = isset($resp['error_description']) ? $resp['error_description'] : $errorCode;
switch ($errorCode) {
case 'invalid_client':
return new Error\OAuth\InvalidClient($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
case 'invalid_grant':
return new Error\OAuth\InvalidGrant($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
case 'invalid_request':
return new Error\OAuth\InvalidRequest($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
case 'invalid_scope':
return new Error\OAuth\InvalidScope($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
case 'unsupported_grant_type':
return new Error\OAuth\UnsupportedGrantType($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
case 'unsupported_response_type':
return new Error\OAuth\UnsupportedResponseType($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
}
return null;
}
private static function _formatAppInfo($appInfo)
{
if ($appInfo !== null) {
@ -137,44 +174,34 @@ class ApiRequestor
}
}
private static function _defaultHeaders($apiKey)
private static function _defaultHeaders($apiKey, $clientInfo = null)
{
$appInfo = Stripe::getAppInfo();
$uaString = 'Stripe/v1 PhpBindings/' . Stripe::VERSION;
$langVersion = phpversion();
$uname = php_uname();
$httplib = 'unknown';
$ssllib = 'unknown';
if (function_exists('curl_version')) {
$curlVersion = curl_version();
$httplib = 'curl ' . $curlVersion['version'];
$ssllib = $curlVersion['ssl_version'];
}
$appInfo = Stripe::getAppInfo();
$ua = array(
$ua = [
'bindings_version' => Stripe::VERSION,
'lang' => 'php',
'lang_version' => $langVersion,
'publisher' => 'stripe',
'uname' => $uname,
'httplib' => $httplib,
'ssllib' => $ssllib,
);
];
if ($clientInfo) {
$ua = array_merge($clientInfo, $ua);
}
if ($appInfo !== null) {
$uaString .= ' ' . self::_formatAppInfo($appInfo);
$ua['application'] = $appInfo;
}
$defaultHeaders = array(
$defaultHeaders = [
'X-Stripe-Client-User-Agent' => json_encode($ua),
'User-Agent' => $uaString,
'Authorization' => 'Bearer ' . $apiKey,
);
];
return $defaultHeaders;
}
@ -193,9 +220,17 @@ class ApiRequestor
throw new Error\Authentication($msg);
}
// Clients can supply arbitrary additional keys to be included in the
// X-Stripe-Client-User-Agent header via the optional getUserAgentInfo()
// method
$clientUAInfo = null;
if (method_exists($this->httpClient(), 'getUserAgentInfo')) {
$clientUAInfo = $this->httpClient()->getUserAgentInfo();
}
$absUrl = $this->_apiBase.$url;
$params = self::_encodeObjects($params);
$defaultHeaders = $this->_defaultHeaders($myApiKey);
$defaultHeaders = $this->_defaultHeaders($myApiKey, $clientUAInfo);
if (Stripe::$apiVersion) {
$defaultHeaders['Stripe-Version'] = Stripe::$apiVersion;
}
@ -222,7 +257,7 @@ class ApiRequestor
}
$combinedHeaders = array_merge($defaultHeaders, $headers);
$rawHeaders = array();
$rawHeaders = [];
foreach ($combinedHeaders as $header => $value) {
$rawHeaders[] = $header . ': ' . $value;
@ -235,7 +270,7 @@ class ApiRequestor
$params,
$hasFile
);
return array($rbody, $rcode, $rheaders, $myApiKey);
return [$rbody, $rcode, $rheaders, $myApiKey];
}
private function _processResourceParam($resource, $hasCurlFile)
@ -272,7 +307,7 @@ class ApiRequestor
}
if ($rcode < 200 || $rcode >= 300) {
$this->handleApiError($rbody, $rcode, $rheaders, $resp);
$this->handleErrorResponse($rbody, $rcode, $rheaders, $resp);
}
return $resp;
}

View File

@ -9,11 +9,42 @@ namespace Stripe;
*/
abstract class ApiResource extends StripeObject
{
private static $HEADERS_TO_PERSIST = array('Stripe-Account' => true, 'Stripe-Version' => true);
use ApiOperations\Request;
public static function baseUrl()
/**
* @return \Stripe\Util\Set A list of fields that can be their own type of
* API resource (say a nested card under an account for example), and if
* that resource is set, it should be transmitted to the API on a create or
* update. Doing so is not the default behavior because API resources
* should normally be persisted on their own RESTful endpoints.
*/
public static function getSavedNestedResources()
{
return Stripe::$apiBase;
static $savedNestedResources = null;
if ($savedNestedResources === null) {
$savedNestedResources = new Util\Set();
}
return $savedNestedResources;
}
/**
* @var boolean A flag that can be set a behavior that will cause this
* resource to be encoded and sent up along with an update of its parent
* resource. This is usually not desirable because resources are updated
* individually on their own endpoints, but there are certain cases,
* replacing a customer's source for example, where this is allowed.
*/
public $saveWithParent = false;
public function __set($k, $v)
{
parent::__set($k, $v);
$v = $this->$k;
if ((static::getSavedNestedResources()->includes($k)) &&
($v instanceof ApiResource)) {
$v->saveWithParent = true;
}
return $v;
}
/**
@ -59,6 +90,14 @@ abstract class ApiResource extends StripeObject
return $name;
}
/**
* @return string The base URL for the given class.
*/
public static function baseUrl()
{
return Stripe::$apiBase;
}
/**
* @return string The endpoint URL for the given class.
*/
@ -92,112 +131,4 @@ abstract class ApiResource extends StripeObject
{
return static::resourceUrl($this['id']);
}
protected static function _validateParams($params = null)
{
if ($params && !is_array($params)) {
$message = "You must pass an array as the first argument to Stripe API "
. "method calls. (HINT: an example call to create a charge "
. "would be: \"Stripe\\Charge::create(array('amount' => 100, "
. "'currency' => 'usd', 'card' => array('number' => "
. "4242424242424242, 'exp_month' => 5, 'exp_year' => 2015)))\")";
throw new Error\Api($message);
}
}
protected function _request($method, $url, $params = array(), $options = null)
{
$opts = $this->_opts->merge($options);
list($resp, $options) = static::_staticRequest($method, $url, $params, $opts);
$this->setLastResponse($resp);
return array($resp->json, $options);
}
protected static function _staticRequest($method, $url, $params, $options)
{
$opts = Util\RequestOptions::parse($options);
$requestor = new ApiRequestor($opts->apiKey, static::baseUrl());
list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
foreach ($opts->headers as $k => $v) {
if (!array_key_exists($k, self::$HEADERS_TO_PERSIST)) {
unset($opts->headers[$k]);
}
}
return array($response, $opts);
}
protected static function _retrieve($id, $options = null)
{
$opts = Util\RequestOptions::parse($options);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
protected static function _all($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('get', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
if (!is_a($obj, 'Stripe\\Collection')) {
$class = get_class($obj);
$message = "Expected type \"Stripe\\Collection\", got \"$class\" instead";
throw new Error\Api($message);
}
$obj->setLastResponse($response);
$obj->setRequestParams($params);
return $obj;
}
protected static function _create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param string $id The ID of the API resource to update.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource the updated API resource
*/
protected static function _update($id, $params = null, $options = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
protected function _save($options = null)
{
$params = $this->serializeParameters();
if (count($params) > 0) {
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
}
return $this;
}
protected function _delete($params = null, $options = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -9,7 +9,11 @@ namespace Stripe;
*/
class ApplePayDomain extends ApiResource
{
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\Retrieve;
/**
* @return string The class URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern.
@ -18,48 +22,4 @@ class ApplePayDomain extends ApiResource
{
return '/v1/apple_pay/domains';
}
/**
* @param string $id The ID of the domain to retrieve.
* @param array|string|null $opts
*
* @return ApplePayDomain
*/
public static function retrieve($id, $opts = null)
{
return self::_retrieve($id, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return ApplePayDomain The created domain.
*/
public static function create($params = null, $opts = null)
{
return self::_create($params, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return ApplePayDomain The deleted domain.
*/
public function delete($params = null, $opts = null)
{
return $this->_delete($params, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection of ApplePayDomains
*/
public static function all($params = null, $opts = null)
{
return self::_all($params, $opts);
}
}

View File

@ -5,10 +5,31 @@ namespace Stripe;
/**
* Class ApplicationFee
*
* @property string $id
* @property string $object
* @property string $account
* @property int $amount
* @property int $amount_refunded
* @property string $application
* @property string $balance_transaction
* @property string $charge
* @property int $created
* @property string $currency
* @property bool $livemode
* @property string $originating_transaction
* @property bool $refunded
* @property Collection $refunds
*
* @package Stripe
*/
class ApplicationFee extends ApiResource
{
use ApiOperations\All;
use ApiOperations\NestedResource;
use ApiOperations\Retrieve;
const PATH_REFUNDS = '/refunds';
/**
* This is a special case because the application fee endpoint has an
* underscore in it. The parent `className` function strips underscores.
@ -20,40 +41,6 @@ class ApplicationFee extends ApiResource
return 'application_fee';
}
/**
* @param string $id The ID of the application fee to retrieve.
* @param array|string|null $opts
*
* @return ApplicationFee
*/
public static function retrieve($id, $opts = null)
{
return self::_retrieve($id, $opts);
}
/**
* @param string $id The ID of the application fee to update.
* @param array|null $params
* @param array|string|null $options
*
* @return ApplicationFee The updated application fee.
*/
public static function update($id, $params = null, $options = null)
{
return self::_update($id, $params, $options);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection of ApplicationFees
*/
public static function all($params = null, $opts = null)
{
return self::_all($params, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
@ -66,4 +53,54 @@ class ApplicationFee extends ApiResource
$this->refresh();
return $this;
}
/**
* @param array|null $id The ID of the application fee on which to create the refund.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApplicationFeeRefund
*/
public static function createRefund($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_REFUNDS, $params, $opts);
}
/**
* @param array|null $id The ID of the application fee to which the refund belongs.
* @param array|null $refundId The ID of the refund to retrieve.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApplicationFeeRefund
*/
public static function retrieveRefund($id, $refundId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
}
/**
* @param array|null $id The ID of the application fee to which the refund belongs.
* @param array|null $refundId The ID of the refund to update.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApplicationFeeRefund
*/
public static function updateRefund($id, $refundId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
}
/**
* @param array|null $id The ID of the application fee on which to retrieve the refunds.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApplicationFeeRefund
*/
public static function allRefunds($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_REFUNDS, $params, $opts);
}
}

View File

@ -5,10 +5,23 @@ namespace Stripe;
/**
* Class ApplicationFeeRefund
*
* @property string $id
* @property string $object
* @property int $amount
* @property string $balance_transaction
* @property int $created
* @property string $currency
* @property string $fee
* @property StripeObject $metadata
*
* @package Stripe
*/
class ApplicationFeeRefund extends ApiResource
{
use ApiOperations\Update {
save as protected _save;
}
/**
* @return string The API URL for this Stripe refund.
*/

View File

@ -1,31 +0,0 @@
<?php
namespace Stripe;
/**
* Class AttachedObject
*
* e.g. metadata on Stripe objects.
*
* @package Stripe
*/
class AttachedObject extends StripeObject
{
/**
* Updates this object.
*
* @param array $properties A mapping of properties to update on this object.
*/
public function replaceWith($properties)
{
$removed = array_diff(array_keys($this->_values), array_keys($properties));
// Don't unset, but rather set to null so we send up '' for deletion.
foreach ($removed as $k) {
$this->$k = null;
}
foreach ($properties as $k => $v) {
$this->$k = $v;
}
}
}

View File

@ -6,9 +6,9 @@ namespace Stripe;
* Class Balance
*
* @property string $object
* @property mixed $available
* @property bool $livedmode
* @property mixed $pending
* @property array $available
* @property bool $livemode
* @property array $pending
*
* @package Stripe
*/

View File

@ -12,11 +12,11 @@ namespace Stripe;
* @property int $created
* @property string $currency
* @property string $description
* @property float $exchange_rate
* @property int $fee
* @property mixed $fee_details
* @property int $net
* @property string $source
* @property mixed $sourced_transfers
* @property string $status
* @property string $type
*
@ -24,6 +24,9 @@ namespace Stripe;
*/
class BalanceTransaction extends ApiResource
{
use ApiOperations\All;
use ApiOperations\Retrieve;
/**
* @return string The class URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern.
@ -32,26 +35,4 @@ class BalanceTransaction extends ApiResource
{
return "/v1/balance/history";
}
/**
* @param string $id The ID of the balance transaction to retrieve.
* @param array|string|null $opts
*
* @return BalanceTransaction
*/
public static function retrieve($id, $opts = null)
{
return self::_retrieve($id, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection of BalanceTransactions
*/
public static function all($params = null, $opts = null)
{
return self::_all($params, $opts);
}
}

View File

@ -5,11 +5,82 @@ namespace Stripe;
/**
* Class BankAccount
*
* @property string $id
* @property string $object
* @property string $account
* @property string $account_holder_name
* @property string $account_holder_type
* @property string $bank_name
* @property string $country
* @property string $currency
* @property string $customer
* @property bool $default_for_currency
* @property string $fingerprint
* @property string $last4
* @property StripeObject $metadata
* @property string $routing_number
* @property string $status
*
* @package Stripe
*/
class BankAccount extends ExternalAccount
class BankAccount extends ApiResource
{
use ApiOperations\Delete;
use ApiOperations\Update;
/**
* @return string The instance URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern.
*/
public function instanceUrl()
{
if ($this['customer']) {
$base = Customer::classUrl();
$parent = $this['customer'];
$path = 'sources';
} elseif ($this['account']) {
$base = Account::classUrl();
$parent = $this['account'];
$path = 'external_accounts';
} else {
$msg = "Bank accounts cannot be accessed without a customer ID or account ID.";
throw new Error\InvalidRequest($msg, null);
}
$parentExtn = urlencode(Util\Util::utf8($parent));
$extn = urlencode(Util\Util::utf8($this['id']));
return "$base/$parentExtn/$path/$extn";
}
/**
* @param array|string $_id
* @param array|string|null $_opts
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function retrieve($_id, $_opts = null)
{
$msg = "Bank accounts cannot be accessed without a customer ID or account ID. " .
"Retrieve a bank account using \$customer->sources->retrieve('bank_account_id') or " .
"\$account->external_accounts->retrieve('bank_account_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
/**
* @param string $_id
* @param array|null $_params
* @param array|string|null $_options
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = "Bank accounts cannot be accessed without a customer ID or account ID. " .
"Call save() on \$customer->sources->retrieve('bank_account_id') or " .
"\$account->external_accounts->retrieve('bank_account_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
/**
* @param array|null $params
* @param array|string|null $options
*

View File

@ -6,9 +6,15 @@ namespace Stripe;
* Class BitcoinReceiver
*
* @package Stripe
*
* @deprecated Bitcoin receivers are deprecated. Please use the sources API instead.
* @link https://stripe.com/docs/sources/bitcoin
*/
class BitcoinReceiver extends ExternalAccount
class BitcoinReceiver extends ApiResource
{
use ApiOperations\All;
use ApiOperations\Retrieve;
/**
* @return string The class URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern.
@ -24,62 +30,17 @@ class BitcoinReceiver extends ExternalAccount
*/
public function instanceUrl()
{
$result = parent::instanceUrl();
if ($result) {
return $result;
if ($this['customer']) {
$base = Customer::classUrl();
$parent = $this['customer'];
$path = 'sources';
$parentExtn = urlencode(Util\Util::utf8($parent));
$extn = urlencode(Util\Util::utf8($this['id']));
return "$base/$parentExtn/$path/$extn";
} else {
$id = $this['id'];
$id = Util\Util::utf8($id);
$extn = urlencode($id);
$base = BitcoinReceiver::classUrl();
$extn = urlencode(Util\Util::utf8($this['id']));
return "$base/$extn";
}
}
/**
* @param string $id The ID of the Bitcoin Receiver to retrieve.
* @param array|string|null $opts
*
* @return BitcoinReceiver
*/
public static function retrieve($id, $opts = null)
{
return self::_retrieve($id, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection of BitcoinReceivers
*/
public static function all($params = null, $opts = null)
{
return self::_all($params, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return BitcoinReceiver The created Bitcoin Receiver item.
*/
public static function create($params = null, $opts = null)
{
return self::_create($params, $opts);
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return BitcoinReceiver The refunded Bitcoin Receiver item.
*/
public function refund($params = null, $options = null)
{
$url = $this->instanceUrl() . '/refund';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -5,9 +5,93 @@ namespace Stripe;
/**
* Class Card
*
* @property string $id
* @property string $object
* @property string $address_city
* @property string $address_country
* @property string $address_line1
* @property string $address_line1_check
* @property string $address_line2
* @property string $address_state
* @property string $address_zip
* @property string $address_zip_check
* @property string $brand
* @property string $country
* @property string $customer
* @property string $cvc_check
* @property string $dynamic_last4
* @property int $exp_month
* @property int $exp_year
* @property string $fingerprint
* @property string $funding
* @property string $last4
* @property StripeObject $metadata
* @property string $name
* @property string $tokenization_method
*
* @package Stripe
*/
class Card extends ExternalAccount
class Card extends ApiResource
{
use ApiOperations\Delete;
use ApiOperations\Update;
/**
* @return string The instance URL for this resource. It needs to be special
* cased because cards are nested resources that may belong to different
* top-level resources.
*/
public function instanceUrl()
{
if ($this['customer']) {
$base = Customer::classUrl();
$parent = $this['customer'];
$path = 'sources';
} elseif ($this['account']) {
$base = Account::classUrl();
$parent = $this['account'];
$path = 'external_accounts';
} elseif ($this['recipient']) {
$base = Recipient::classUrl();
$parent = $this['recipient'];
$path = 'cards';
} else {
$msg = "Cards cannot be accessed without a customer ID, account ID or recipient ID.";
throw new Error\InvalidRequest($msg, null);
}
$parentExtn = urlencode(Util\Util::utf8($parent));
$extn = urlencode(Util\Util::utf8($this['id']));
return "$base/$parentExtn/$path/$extn";
}
/**
* @param array|string $_id
* @param array|string|null $_opts
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function retrieve($_id, $_opts = null)
{
$msg = "Cards cannot be accessed without a customer, recipient or account ID. " .
"Retrieve a card using \$customer->sources->retrieve('card_id'), " .
"\$recipient->cards->retrieve('card_id'), or";
"\$account->external_accounts->retrieve('card_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
/**
* @param string $_id
* @param array|null $_params
* @param array|string|null $_options
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = "Cards cannot be accessed without a customer, recipient or account ID. " .
"Call save() on \$customer->sources->retrieve('card_id'), " .
"\$recipient->cards->retrieve('card_id'), or";
"\$account->external_accounts->retrieve('card_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
}

View File

@ -9,91 +9,47 @@ namespace Stripe;
* @property string $object
* @property int $amount
* @property int $amount_refunded
* @property mixed $application_fee
* @property string $application
* @property string $application_fee
* @property string $balance_transaction
* @property bool $captured
* @property int $created
* @property string $currency
* @property string $customer
* @property mixed $description
* @property mixed $destination
* @property string|null $dispute
* @property mixed $failure_code
* @property mixed $failure_message
* @property string $description
* @property string $destination
* @property string $dispute
* @property string $failure_code
* @property string $failure_message
* @property mixed $fraud_details
* @property mixed $invoice
* @property string $invoice
* @property bool $livemode
* @property mixed $metadata
* @property mixed $order
* @property StripeObject $metadata
* @property string $on_behalf_of
* @property string $order
* @property mixed $outcome
* @property bool $paid
* @property mixed $receipt_email
* @property mixed $receipt_number
* @property string $receipt_email
* @property string $receipt_number
* @property bool $refunded
* @property mixed $refunds
* @property Collection $refunds
* @property string $review
* @property mixed $shipping
* @property mixed $source
* @property mixed $source_transfer
* @property mixed $statement_descriptor
* @property string $source_transfer
* @property string $statement_descriptor
* @property string $status
* @property string $transfer
* @property string $transfer_group
*
* @package Stripe
*/
class Charge extends ApiResource
{
/**
* @param string $id The ID of the charge to retrieve.
* @param array|string|null $options
*
* @return Charge
*/
public static function retrieve($id, $options = null)
{
return self::_retrieve($id, $options);
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return Collection of Charges
*/
public static function all($params = null, $options = null)
{
return self::_all($params, $options);
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return Charge The created charge.
*/
public static function create($params = null, $options = null)
{
return self::_create($params, $options);
}
/**
* @param string $id The ID of the charge to update.
* @param array|null $params
* @param array|string|null $options
*
* @return Charge The updated charge.
*/
public static function update($id, $params = null, $options = null)
{
return self::_update($id, $params, $options);
}
/**
* @param array|string|null $options
*
* @return Charge The saved charge.
*/
public function save($options = null)
{
return $this->_save($options);
}
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* @param array|null $params
@ -135,7 +91,7 @@ class Charge extends ApiResource
{
$url = $this->instanceUrl() . '/dispute';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom(array('dispute' => $response), $opts, true);
$this->refreshFrom(['dispute' => $response], $opts, true);
return $this->dispute;
}
@ -161,7 +117,7 @@ class Charge extends ApiResource
*/
public function markAsFraudulent($opts = null)
{
$params = array('fraud_details' => array('user_report' => 'fraudulent'));
$params = ['fraud_details' => ['user_report' => 'fraudulent']];
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
@ -175,7 +131,7 @@ class Charge extends ApiResource
*/
public function markAsSafe($opts = null)
{
$params = array('fraud_details' => array('user_report' => 'safe'));
$params = ['fraud_details' => ['user_report' => 'safe']];
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);

View File

@ -12,9 +12,19 @@ namespace Stripe;
*
* @package Stripe
*/
class Collection extends ApiResource
class Collection extends StripeObject
{
protected $_requestParams = array();
use ApiOperations\Request;
protected $_requestParams = [];
/**
* @return string The base URL for the given class.
*/
public static function baseUrl()
{
return Stripe::$apiBase;
}
public function setRequestParams($params)
{
@ -56,7 +66,7 @@ class Collection extends ApiResource
}
/**
* @return AutoPagingIterator An iterator that can be used to iterate
* @return Util\AutoPagingIterator An iterator that can be used to iterate
* across all objects across all pages. As page boundaries are
* encountered, the next page will be fetched automatically for
* continued iteration.
@ -76,12 +86,11 @@ class Collection extends ApiResource
if (isset($url['query'])) {
// If the URL contains a query param, parse it out into $params so they
// don't interact weirdly with each other.
$query = array();
$query = [];
parse_str($url['query'], $query);
// PHP 5.2 doesn't support the ?: operator :(
$params = array_merge($params ? $params : array(), $query);
$params = array_merge($params ?: [], $query);
}
return array($url['path'], $params);
return [$url['path'], $params];
}
}

View File

@ -5,10 +5,21 @@ namespace Stripe;
/**
* Class CountrySpec
*
* @property string $id
* @property string $object
* @property string $default_currency
* @property mixed $supported_bank_account_currencies
* @property string[] $supported_payment_currencies
* @property string[] $supported_payment_methods
* @property mixed $verification_fields
*
* @package Stripe
*/
class CountrySpec extends ApiResource
{
use ApiOperations\All;
use ApiOperations\Retrieve;
/**
* This is a special case because the country specs endpoint has an
* underscore in it. The parent `className` function strips underscores.
@ -19,26 +30,4 @@ class CountrySpec extends ApiResource
{
return 'country_spec';
}
/**
* @param string $country The ISO country code of the country we retrieve the CountrySpec for.
* @param array|string|null $opts
*
* @return CountrySpec
*/
public static function retrieve($country, $opts = null)
{
return self::_retrieve($country, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection of CountrySpecs
*/
public static function all($params = null, $opts = null)
{
return self::_all($params, $opts);
}
}

View File

@ -5,73 +5,28 @@ namespace Stripe;
/**
* Class Coupon
*
* @property string $id
* @property string $object
* @property int $amount_off
* @property int $created
* @property string $currency
* @property string $duration
* @property int $duration_in_months
* @property bool $livemode
* @property int $max_redemptions
* @property StripeObject $metadata
* @property int $percent_off
* @property int $redeem_by
* @property int $times_redeemed
* @property bool $valid
*
* @package Stripe
*/
class Coupon extends ApiResource
{
/**
* @param string $id The ID of the coupon to retrieve.
* @param array|string|null $opts
*
* @return Coupon
*/
public static function retrieve($id, $opts = null)
{
return self::_retrieve($id, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Coupon The created coupon.
*/
public static function create($params = null, $opts = null)
{
return self::_create($params, $opts);
}
/**
* @param string $id The ID of the coupon to update.
* @param array|null $params
* @param array|string|null $options
*
* @return Coupon The updated coupon.
*/
public static function update($id, $params = null, $options = null)
{
return self::_update($id, $params, $options);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Coupon The deleted coupon.
*/
public function delete($params = null, $opts = null)
{
return $this->_delete($params, $opts);
}
/**
* @param array|string|null $opts
*
* @return Coupon The saved coupon.
*/
public function save($opts = null)
{
return $this->_save($opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection of Coupons
*/
public static function all($params = null, $opts = null)
{
return self::_all($params, $opts);
}
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\Retrieve;
use ApiOperations\Update;
}

View File

@ -17,7 +17,7 @@ namespace Stripe;
* @property mixed $discount
* @property string $email
* @property bool $livemode
* @property array $metadata
* @property StripeObject $metadata
* @property mixed $shipping
* @property Collection $sources
* @property Collection $subscriptions
@ -26,71 +26,25 @@ namespace Stripe;
*/
class Customer extends ApiResource
{
/**
* @param string $id The ID of the customer to retrieve.
* @param array|string|null $opts
*
* @return Customer
*/
public static function retrieve($id, $opts = null)
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\NestedResource;
use ApiOperations\Retrieve;
use ApiOperations\Update;
public static function getSavedNestedResources()
{
return self::_retrieve($id, $opts);
static $savedNestedResources = null;
if ($savedNestedResources === null) {
$savedNestedResources = new Util\Set([
'source',
]);
}
return $savedNestedResources;
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection of Customers
*/
public static function all($params = null, $opts = null)
{
return self::_all($params, $opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Customer The created customer.
*/
public static function create($params = null, $opts = null)
{
return self::_create($params, $opts);
}
/**
* @param string $id The ID of the customer to update.
* @param array|null $params
* @param array|string|null $options
*
* @return Customer The updated customer.
*/
public static function update($id, $params = null, $options = null)
{
return self::_update($id, $params, $options);
}
/**
* @param array|string|null $opts
*
* @return Customer The saved customer.
*/
public function save($opts = null)
{
return $this->_save($opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Customer The deleted customer.
*/
public function delete($params = null, $opts = null)
{
return $this->_delete($params, $opts);
}
const PATH_SOURCES = '/sources';
/**
* @param array|null $params
@ -99,9 +53,7 @@ class Customer extends ApiResource
*/
public function addInvoiceItem($params = null)
{
if (!$params) {
$params = array();
}
$params = $params ?: [];
$params['customer'] = $this->id;
$ii = InvoiceItem::create($params, $this->_opts);
return $ii;
@ -114,9 +66,7 @@ class Customer extends ApiResource
*/
public function invoices($params = null)
{
if (!$params) {
$params = array();
}
$params = $params ?: [];
$params['customer'] = $this->id;
$invoices = Invoice::all($params, $this->_opts);
return $invoices;
@ -129,9 +79,7 @@ class Customer extends ApiResource
*/
public function invoiceItems($params = null)
{
if (!$params) {
$params = array();
}
$params = $params ?: [];
$params['customer'] = $this->id;
$iis = InvoiceItem::all($params, $this->_opts);
return $iis;
@ -144,9 +92,7 @@ class Customer extends ApiResource
*/
public function charges($params = null)
{
if (!$params) {
$params = array();
}
$params = $params ?: [];
$params['customer'] = $this->id;
$charges = Charge::all($params, $this->_opts);
return $charges;
@ -161,7 +107,7 @@ class Customer extends ApiResource
{
$url = $this->instanceUrl() . '/subscription';
list($response, $opts) = $this->_request('post', $url, $params);
$this->refreshFrom(array('subscription' => $response), $opts, true);
$this->refreshFrom(['subscription' => $response], $opts, true);
return $this->subscription;
}
@ -174,7 +120,7 @@ class Customer extends ApiResource
{
$url = $this->instanceUrl() . '/subscription';
list($response, $opts) = $this->_request('delete', $url, $params);
$this->refreshFrom(array('subscription' => $response), $opts, true);
$this->refreshFrom(['subscription' => $response], $opts, true);
return $this->subscription;
}
@ -185,6 +131,69 @@ class Customer extends ApiResource
{
$url = $this->instanceUrl() . '/discount';
list($response, $opts) = $this->_request('delete', $url);
$this->refreshFrom(array('discount' => null), $opts, true);
$this->refreshFrom(['discount' => null], $opts, true);
}
/**
* @param array|null $id The ID of the customer on which to create the source.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function createSource($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_SOURCES, $params, $opts);
}
/**
* @param array|null $id The ID of the customer to which the source belongs.
* @param array|null $sourceId The ID of the source to retrieve.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function retrieveSource($id, $sourceId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
}
/**
* @param array|null $id The ID of the customer to which the source belongs.
* @param array|null $sourceId The ID of the source to update.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function updateSource($id, $sourceId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
}
/**
* @param array|null $id The ID of the customer to which the source belongs.
* @param array|null $sourceId The ID of the source to delete.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function deleteSource($id, $sourceId, $params = null, $opts = null)
{
return self::_deleteNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
}
/**
* @param array|null $id The ID of the customer on which to retrieve the sources.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function allSources($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_SOURCES, $params, $opts);
}
}

View File

@ -16,7 +16,7 @@ namespace Stripe;
* @property mixed $evidence_details
* @property bool $is_charge_refundable
* @property bool $livemode
* @property mixed $metadata
* @property StripeObject $metadata
* @property string $reason
* @property string $status
*
@ -24,49 +24,40 @@ namespace Stripe;
*/
class Dispute extends ApiResource
{
/**
* @param string $id The ID of the dispute to retrieve.
* @param array|string|null $options
*
* @return Dispute
*/
public static function retrieve($id, $options = null)
{
return self::_retrieve($id, $options);
}
use ApiOperations\All;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* @param array|null $params
* @param array|string|null $options
*
* @return array An array of Disputes.
* Possible string representations of dispute reasons.
* @link https://stripe.com/docs/api#dispute_object
*/
public static function all($params = null, $options = null)
{
return self::_all($params, $options);
}
const REASON_BANK_CANNOT_PROCESS = 'bank_cannot_process';
const REASON_CREDIT_NOT_PROCESSED = 'credit_not_processed';
const REASON_CUSTOMER_INITIATED = 'customer_initiated';
const REASON_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized';
const REASON_DUPLICATE = 'duplicate';
const REASON_FRAUDULENT = 'fraudulent';
const REASON_GENERAL = 'general';
const REASON_INCORRECT_ACCOUNT_DETAILS = 'incorrect_account_details';
const REASON_INSUFFICIENT_FUNDS = 'insufficient_funds';
const REASON_PRODUCT_NOT_RECEIVED = 'product_not_received';
const REASON_PRODUCT_UNACCEPTABLE = 'product_unacceptable';
const REASON_SUBSCRIPTION_CANCELED = 'subscription_canceled';
const REASON_UNRECOGNIZED = 'unrecognized';
/**
* @param string $id The ID of the dispute to update.
* @param array|null $params
* @param array|string|null $options
*
* @return Dispute The updated dispute.
* Possible string representations of dispute statuses.
* @link https://stripe.com/docs/api#dispute_object
*/
public static function update($id, $params = null, $options = null)
{
return self::_update($id, $params, $options);
}
/**
* @param array|string|null $options
*
* @return Dispute The saved charge.
*/
public function save($options = null)
{
return $this->_save($options);
}
const STATUS_CHARGE_REFUNDED = 'charge_refunded';
const STATUS_LOST = 'lost';
const STATUS_NEEDS_RESPONSE = 'needs_response';
const STATUS_UNDER_REVIEW = 'under_review';
const STATUS_WARNING_CLOSED = 'warning_closed';
const STATUS_WARNING_NEEDS_RESPONSE = 'warning_needs_response';
const STATUS_WARNING_UNDER_REVIEW = 'warning_under_review';
const STATUS_WON = 'won';
/**
* @param array|string|null $options

View File

@ -0,0 +1,49 @@
<?php
namespace Stripe;
/**
* Class EphemeralKey
*
* @property string $id
* @property string $object
* @property int $created
* @property int $expires
* @property bool $livemode
* @property string $secret
* @property array $associated_objects
*
* @package Stripe
*/
class EphemeralKey extends ApiResource
{
use ApiOperations\Create {
create as protected _create;
}
use ApiOperations\Delete;
/**
* This is a special case because the ephemeral key endpoint has an
* underscore in it. The parent `className` function strips underscores.
*
* @return string The name of the class.
*/
public static function className()
{
return 'ephemeral_key';
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return EphemeralKey The created key.
*/
public static function create($params = null, $opts = null)
{
if (!$opts['stripe_version']) {
throw new \InvalidArgumentException('stripe_version must be specified to create an ephemeral key');
}
return self::_create($params, $opts);
}
}

View File

@ -20,11 +20,20 @@ abstract class Base extends Exception
$this->httpHeaders = $httpHeaders;
$this->requestId = null;
// TODO: make this a proper constructor argument in the next major
// release.
$this->stripeCode = isset($jsonBody["error"]["code"]) ? $jsonBody["error"]["code"] : null;
if ($httpHeaders && isset($httpHeaders['Request-Id'])) {
$this->requestId = $httpHeaders['Request-Id'];
}
}
public function getStripeCode()
{
return $this->stripeCode;
}
public function getHttpStatus()
{
return $this->httpStatus;

View File

@ -15,12 +15,16 @@ class Card extends Base
) {
parent::__construct($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders);
$this->stripeParam = $stripeParam;
// TODO: once Error\Base accepts the error code as an argument, pass it
// in the call to parent::__construct() and stop setting it here.
$this->stripeCode = $stripeCode;
// This one is not like the others because it was added later and we're
// trying to do our best not to change the public interface of this class'
// constructor. We should consider changing its implementation on the
// next major version bump of this library.
// constructor.
// TODO: make this a proper constructor argument in the next major
// release.
$this->declineCode = isset($jsonBody["error"]["decline_code"]) ? $jsonBody["error"]["decline_code"] : null;
}
@ -29,11 +33,6 @@ class Card extends Base
return $this->declineCode;
}
public function getStripeCode()
{
return $this->stripeCode;
}
public function getStripeParam()
{
return $this->stripeParam;

View File

@ -0,0 +1,7 @@
<?php
namespace Stripe\Error;
class Idempotency extends Base
{
}

View File

@ -0,0 +1,10 @@
<?php
namespace Stripe\Error\OAuth;
/**
* InvalidClient is raised when authentication fails.
*/
class InvalidClient extends OAuthBase
{
}

View File

@ -0,0 +1,13 @@
<?php
namespace Stripe\Error\OAuth;
/**
* InvalidGrant is raised when a specified code doesn't exist, is
* expired, has been used, or doesn't belong to you; a refresh token doesn't
* exist, or doesn't belong to you; or if an API key's mode (live or test)
* doesn't match the mode of a code or refresh token.
*/
class InvalidGrant extends OAuthBase
{
}

View File

@ -0,0 +1,11 @@
<?php
namespace Stripe\Error\OAuth;
/**
* InvalidRequest is raised when a code, refresh token, or grant type
* parameter is not provided, but was required.
*/
class InvalidRequest extends OAuthBase
{
}

Some files were not shown because too many files have changed in this diff Show More