Merge branch 'develop' into ptibogxiv-stripe

This commit is contained in:
Laurent Destailleur 2018-03-08 16:29:27 +01:00 committed by GitHub
commit 936aef70a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
203 changed files with 6794 additions and 4510 deletions

View File

@ -1330,19 +1330,19 @@ class Adherent extends CommonObject
/**
* Do complementary actions after subscription recording.
*
* @param int $subscriptionid Id of created subscription
* @param string $option Which action ('bankdirect', 'invoiceonly', ...)
* @param int $accountid Id bank account
* @param int $datesubscription Date of subscription
* @param int $paymentdate Date of payment
* @param string $operation Code of type of operation (if Id bank account provided). Example 'CB', ...
* @param string $label Label operation (if Id bank account provided)
* @param double $amount Amount of subscription (0 accepted for some members)
* @param string $num_chq Numero cheque (if Id bank account provided)
* @param string $emetteur_nom Name of cheque writer
* @param string $emetteur_banque Name of bank of cheque
* @param int $subscriptionid Id of created subscription
* @param string $option Which action ('bankdirect', 'invoiceonly', ...)
* @param int $accountid Id bank account
* @param int $datesubscription Date of subscription
* @param int $paymentdate Date of payment
* @param string $operation Code of type of operation (if Id bank account provided). Example 'CB', ...
* @param string $label Label operation (if Id bank account provided)
* @param double $amount Amount of subscription (0 accepted for some members)
* @param string $num_chq Numero cheque (if Id bank account provided)
* @param string $emetteur_nom Name of cheque writer
* @param string $emetteur_banque Name of bank of cheque
* @param string $autocreatethirdparty Auto create new thirdparty if member not linked to a thirdparty.
* @return int <0 if KO, >0 if OK
* @return int <0 if KO, >0 if OK
*/
function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom='', $emetteur_banque='', $autocreatethirdparty=0)
{
@ -1350,6 +1350,8 @@ class Adherent extends CommonObject
$error = 0;
$this->invoice = null; // This will contains invoice if an invoice is created
// Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect'
if ($option == 'bankdirect' && $accountid)
{
@ -1489,6 +1491,10 @@ class Adherent extends CommonObject
$this->errors=$invoice->errors;
$error++;
}
else
{
$this->invoice = $invoice;
}
}
if (! $error)
@ -1524,6 +1530,11 @@ class Adherent extends CommonObject
}
}
if (! $error)
{
// TODO Link invoice with subscription ?
}
// Add payment onto invoice
if (! $error && $option == 'bankviainvoice' && $accountid)
{
@ -1584,25 +1595,25 @@ class Adherent extends CommonObject
// Set invoice as paid
$invoice->set_paid($user);
}
}
if (! $error)
{
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $customer->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
// Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email
//if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if (! $error)
{
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
$newlang = $_REQUEST['lang_id'];
if ($conf->global->MAIN_MULTILANGS && empty($newlang))
$newlang = $customer->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
// Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email
//if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$invoice->generateDocument($invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}

View File

@ -322,11 +322,15 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
else
{
// If an invoice was created, it is into $object->invoice
}
}
if (! $error)
{
$db->commit();
// $db->commit();
}
else
{
@ -334,6 +338,11 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$action = 'addsubscription';
}
if (! $error)
{
setEventMessages("SubscriptionRecorded", null, 'mesgs');
}
// Send email
if (! $error)
{
@ -343,12 +352,36 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
$texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
$result=$object->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1);
// Attach a file ?
$file='';
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
if (is_object($object->invoice))
{
$invoicediroutput = $conf->facture->dir_output;
$fileparams = dol_most_recent_file($invoicediroutput . '/' . $object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+');
$file = $fileparams['fullname'];
$listofpaths=array($file);
$listofnames=array(basename($file));
$listofmimes=array(dol_mimetype($file));
}
$result=$object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofnames, $listofmimes, "", "", 0, -1);
if ($result < 0)
{
$errmsg=$object->error;
setEventMessages($errmsg, null, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
else
{
setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs');
}
}
else
{
setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs');
}
}
@ -998,7 +1031,7 @@ if ($rowid > 0)
$helpcontent.='<b>'.$langs->trans("MailText").'</b>:<br>';
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
print $form->textwithpicto($tmp,$helpcontent,1,'help');
print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend');
}
print '</td></tr>';
print '</tbody>';

View File

@ -383,8 +383,8 @@ $tabrowid[8] = "id";
$tabrowid[9] = "code_iso";
$tabrowid[10]= "";
$tabrowid[11]= "rowid";
$tabrowid[12]= "rowid";
$tabrowid[13]= "id";
$tabrowid[12]= "";
$tabrowid[13]= "";
$tabrowid[14]= "";
$tabrowid[15]= "";
$tabrowid[16]= "code";

View File

@ -66,7 +66,8 @@ class Setup extends DolibarrApi
$sql = "SELECT id, code, type, libelle as label, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t";
$sql.= " WHERE t.active = ".$active;
$sql.= " WHERE t.entity IN (".getEntity('c_paiement').")";
$sql.= " AND t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{
@ -538,7 +539,8 @@ class Setup extends DolibarrApi
$sql = "SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
$sql.= " WHERE t.active = ".$active;
$sql.= " WHERE t.entity IN (".getEntity('c_payment_term').")";
$sql.= " AND t.active = ".$active;
// Add sql filters
if ($sqlfilters)
{

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

@ -1343,8 +1343,8 @@ class Propal extends CommonObject
$sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc";
$sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement";
$sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity IN ('.getEntity('c_paiement').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity IN ('.getEntity('c_payment_term').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';

View File

@ -1584,8 +1584,8 @@ class Commande extends CommonOrder
$sql.= ', ca.code as availability_code, ca.label as availability_label';
$sql.= ', dr.code as demand_reason_code';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid AND cr.entity IN ('.getEntity('c_payment_term').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';

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

@ -102,7 +102,7 @@ $sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,";
$sql.= " pst.code as payment_code";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id AND pst.entity IN (" . getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " WHERE v.entity IN (".getEntity('payment_various').")";
@ -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

@ -139,7 +139,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " WHERE cs.fk_type = c.id";
@ -260,7 +260,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
$sql.= " FROM ".MAIN_DB_PREFIX."tva as pv";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id AND pct.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id";
$sql.= " WHERE pv.entity IN (".getEntity("tax").")";
if ($year > 0)
{
@ -474,7 +474,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id AND pct.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id";
$sql.= " , ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE s.entity IN (".getEntity('user').")";
$sql.= " AND u.rowid = s.fk_user";

View File

@ -716,7 +716,7 @@ if (empty($reshook))
$sql = 'SELECT SUM(pf.amount) as total_paiements';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN (' . getEntity('c_paiement') . ')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql.= ' WHERE pf.fk_facture = '.$object->id;
$sql.= ' AND pf.fk_paiement = p.rowid';
$sql.= ' AND p.entity IN (' . getEntity('facture').')';

View File

@ -304,8 +304,8 @@ class FactureRec extends CommonInvoice
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
//$sql.= ', el.fk_source';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity IN ('.getEntity('c_payment_term').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'";
$sql.= ' WHERE f.entity IN ('.getEntity('facture').')';
if ($rowid) $sql.= ' AND f.rowid='.$rowid;

View File

@ -1256,8 +1256,8 @@ class Facture extends CommonInvoice
$sql.= ', f.fk_incoterms, f.location_incoterms';
$sql.= ", i.libelle as libelle_incoterms";
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid AND c.entity IN (' . getEntity('c_payment_term').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid';
$sql.= ' WHERE f.entity IN ('.getEntity('facture').')';
if ($rowid) $sql.= " AND f.rowid=".$rowid;

View File

@ -90,7 +90,6 @@ class PaymentTerm // extends CommonObject
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_payment_term(";
$sql.= "rowid,";
$sql.= "entity,";
$sql.= "code,";
$sql.= "sortorder,";
@ -101,7 +100,6 @@ class PaymentTerm // extends CommonObject
$sql.= "nbjour,";
$sql.= "decalage";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->db->escape($this->rowid)."'").",";
$sql.= " ".(! isset($this->entity)?getEntity('c_payment_term'):"'".$this->db->escape($this->entity)."'").",";
$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
$sql.= " ".(! isset($this->sortorder)?'NULL':"'".$this->db->escape($this->sortorder)."'").",";
@ -181,7 +179,6 @@ class PaymentTerm // extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
$sql.= " WHERE t.rowid = ".$id;
$sql.= " AND t.entity = " . getEntity('c_payment_term');
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
@ -221,36 +218,36 @@ class PaymentTerm // extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
function getDefaultId()
{
global $langs;
function getDefaultId()
{
global $langs;
$ret=0;
$ret=0;
$sql = "SELECT";
$sql = "SELECT";
$sql.= " t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
$sql.= " WHERE t.code = 'RECEP'";
$sql.= " AND t.entity = " . getEntity('c_payment_term');
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
$sql.= " WHERE t.code = 'RECEP'";
$sql.= " AND t.entity IN (".getEntity('c_payment_term').")";
dol_syslog(get_class($this)."::getDefaultId", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
if ($obj) $ret=$obj->rowid;
}
$this->db->free($resql);
return $ret;
}
else
{
$this->error="Error ".$this->db->lasterror();
return -1;
}
}
dol_syslog(get_class($this)."::getDefaultId", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
if ($obj) $ret=$obj->rowid;
}
$this->db->free($resql);
return $ret;
}
else
{
$this->error="Error ".$this->db->lasterror();
return -1;
}
}
/**
@ -293,7 +290,6 @@ class PaymentTerm // extends CommonObject
$sql.= " nbjour=".(isset($this->nbjour)?$this->nbjour:"null").",";
$sql.= " decalage=".(isset($this->decalage)?$this->decalage:"null")."";
$sql.= " WHERE rowid = " . $this->id;
$sql.= " AND entity = " . getEntity('c_payment_term');
$this->db->begin();
@ -350,7 +346,6 @@ class PaymentTerm // extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_payment_term";
$sql.= " WHERE rowid = " . $this->id;
$sql.= " AND t.entity = " . getEntity('c_payment_term');
$this->db->begin();

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

@ -702,18 +702,18 @@ if ($resql)
if (! empty($arrayfields['f.date']['checked']))
{
print '<td class="liste_titre nowraponall" 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, 0, 0, '', 'width75');
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 nowraponall" 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, 0, 0, '', 'width75');
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

@ -827,7 +827,7 @@ if (! GETPOST('action','aZ09'))
$sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.facnumber';
$sql.=', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN (' . getEntity('c_paiement').')';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql.= ', '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' WHERE p.fk_facture = f.rowid';
$sql.= ' AND f.entity IN (' . getEntity('facture').')';

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

@ -107,7 +107,7 @@ class Cpaiement
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
$sql.= 'id,';
$sql.= 'entity,';
$sql.= 'code,';
$sql.= 'libelle,';
$sql.= 'type,';
@ -118,7 +118,7 @@ class Cpaiement
$sql .= ') VALUES (';
$sql .= ' '.(! isset($this->id)?'NULL':$this->id).',';
$sql .= ' '.(! isset($this->entity)?getEntity('c_paiement'):$this->entity).',';
$sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").',';
$sql .= ' '.(! isset($this->libelle)?'NULL':"'".$this->db->escape($this->libelle)."'").',';
$sql .= ' '.(! isset($this->type)?'NULL':$this->type).',';
@ -186,7 +186,8 @@ class Cpaiement
$sql .= " t.module";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
if (null !== $ref) {
$sql .= ' WHERE t.code = ' . '\'' . $ref . '\'';
$sql .= ' WHERE t.entity IN ('.getEntity('c_paiement').')';
$sql .= ' AND t.code = ' . '\'' . $ref . '\'';
} else {
$sql .= ' WHERE t.id = ' . $id;
}

View File

@ -138,7 +138,7 @@ else
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id AND c.entity IN (" . getEntity('c_paiement') . ")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";

View File

@ -822,7 +822,7 @@ else
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
$sql.= " AND p.fk_statut>=5";
@ -906,7 +906,7 @@ else
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql.= " WHERE p.entity IN (".getEntity('donation').")";
$sql.= " AND fk_statut >= 2";
}

View File

@ -698,7 +698,7 @@ if (! empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES'
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql.= " WHERE p.entity IN (".getEntity('expensereport').")";
$sql.= " AND p.fk_statut>=5";
@ -761,7 +761,7 @@ if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."don as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id AND c.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql.= " WHERE p.entity IN (".getEntity('donation').")";
$sql.= " AND fk_statut >= 2";
if (! empty($date_start) && ! empty($date_end))

View File

@ -73,7 +73,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
if (empty($datev)) $datev=$datep;
$type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement');
$type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1);
$object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
$object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user","int") : 0;

View File

@ -105,7 +105,7 @@ $sql.= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.da
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,";
$sql.= " pst.code as payment_code";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id AND pst.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,";
$sql.= " ".MAIN_DB_PREFIX."user as u";
@ -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

@ -586,7 +586,7 @@ if ($id > 0)
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid';
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id AND c.entity IN (" . getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " WHERE p.fk_charge = ".$id;
$sql.= " AND p.fk_charge = cs.rowid";

View File

@ -83,7 +83,7 @@ class ChargeSociales extends CommonObject
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id AND p.entity IN ('.getEntity('c_paiement').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id';
$sql.= ' WHERE cs.entity IN ('.getEntity('tax').')';
if ($ref) $sql.= " AND cs.rowid = ".$ref;
else $sql.= " AND cs.rowid = ".$id;

View File

@ -203,7 +203,7 @@ class PaymentSocialContribution extends CommonObject
$sql.= " t.fk_user_modif,";
$sql.= " pt.code as type_code, pt.libelle as type_libelle,";
$sql.= ' b.fk_account';
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id AND pt.entity IN (" . getEntity('c_paiement') . ")";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
$sql.= " WHERE t.rowid = ".$id;
// TODO link on entity of tax;

View File

@ -133,7 +133,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
$sql.= " ".MAIN_DB_PREFIX."chargesociales as cs,";
$sql.= " ".MAIN_DB_PREFIX."paiementcharge as pc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id AND pct.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id";
$sql.= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid";
$sql.= " AND cs.entity = ".$conf->entity;
if ($year > 0)

View File

@ -100,7 +100,7 @@ $bankstatic = new Account($db);
$sql = "SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,";
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id AND pst.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " WHERE t.entity IN (".getEntity('tax').")";
@ -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

@ -602,9 +602,11 @@ abstract class CommonInvoice extends CommonObject
$sqltemp = 'SELECT c.type_cdr,c.nbjour,c.decalage';
$sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c';
$sqltemp.= " WHERE c.entity IN (" . getEntity('c_payment_term').")";
if (is_numeric($cond_reglement)) $sqltemp.= " AND c.rowid=".$cond_reglement;
else $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'";
if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement;
else {
$sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")";
$sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'";
}
dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG);
$resqltemp=$this->db->query($sqltemp);

View File

@ -2793,7 +2793,7 @@ class Form
$sql = "SELECT rowid, code, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_payment_term';
$sql.= " WHERE entity = " . getEntity('c_payment_term');
$sql.= " WHERE entity IN (".getEntity('c_payment_term').")";
$sql.= " AND active > 0";
$sql.= " ORDER BY sortorder";
@ -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

@ -148,16 +148,19 @@ class FormMail extends Form
* Add a file into the list of attached files (stored in SECTION array)
*
* @param string $path Full absolute path on filesystem of file, including file name
* @param string $file Only filename
* @param string $type Mime type
* @param string $file Only filename (can be basename($path))
* @param string $type Mime type (can be dol_mimetype($file))
* @return void
*/
function add_attached_files($path,$file,$type)
function add_attached_files($path, $file='', $type='')
{
$listofpaths=array();
$listofnames=array();
$listofmimes=array();
if (empty($file)) $file=basename($path);
if (empty($type)) $type=dol_mimetype($file);
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);

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/gateway.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Gateways");
$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;

View File

@ -121,11 +121,6 @@ function getEntity($element, $shared=1, $forceentity=null)
{
global $conf, $mc;
// For backward compatibilty
if ($element == 'actioncomm') $element='agenda';
if ($element == 'fichinter') $element='intervention';
if ($element == 'categorie') $element='category';
if (is_object($mc))
{
return $mc->getEntity($element, $shared, $forceentity);

View File

@ -828,7 +828,7 @@ class pdf_crabe extends ModelePDFFactures
$sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
$sql.= " cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id AND cp.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
//$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1";
$sql.= " ORDER BY p.datep";
@ -1688,7 +1688,7 @@ class pdf_crabe extends ModelePDFFactures
{
$top_shift = $pdf->getY() - $current_y;
}
if ($showaddress)
{
// Sender properties

View File

@ -259,7 +259,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement AND pt.entity IN ('.getEntity('c_paiement').')';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pt ON pt.id = p.fk_paiement';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON b.rowid = p.fk_bank';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';

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

@ -165,7 +165,7 @@ class modSalaries extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'payment_salary as p ON p.fk_user = u.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id AND cp.entity IN ('.getEntity('c_paiement').')';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_typepayment = cp.id';
$this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('user').')';
}

View File

@ -283,8 +283,8 @@ class modSociete extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid AND payterm.entity IN ('.getEntity('c_payment_term').')';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id AND paymode.entity IN ('.getEntity('c_paiement').')';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id';
$this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) {
$this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' ';

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

@ -187,7 +187,7 @@ class pdf_paiement
if (! empty($conf->banque->enabled))
$sql.= ", ba.ref as bankaccount";
$sql.= ", p.rowid as prowid";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id AND c.entity IN (" . getEntity('c_paiement').")";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
$sql.= ", ".MAIN_DB_PREFIX."facture as f,";
$sql.= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
if (! empty($conf->banque->enabled))
@ -218,7 +218,7 @@ class pdf_paiement
if (! empty($conf->banque->enabled))
$sql.= ", ba.ref as bankaccount";
$sql.= ", p.rowid as prowid";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id AND c.entity IN (".getEntity('c_paiement').")";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql.= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
if (! empty($conf->banque->enabled))

View File

@ -933,7 +933,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
$sql.= " cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id AND cp.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
$sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id;
$sql.= " ORDER BY p.datep";
$resql=$this->db->query($sql);

View File

@ -643,8 +643,9 @@ if (! empty($id) && $action != 'edit')
* Payments
*/
$sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
$sql.= " c.code as type_code,c.libelle as paiement_type";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON c.entity IN (".getEntity('c_paiement').")";
$sql.= "c.code as type_code,c.libelle as paiement_type";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
$sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
$sql.= ", ".MAIN_DB_PREFIX."don as d";
$sql.= " WHERE d.rowid = '".$id."'";
$sql.= " AND p.fk_donation = d.rowid";

View File

@ -611,7 +611,7 @@ class Don extends CommonObject
$sql.= " c.code as country_code, c.label as country";
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_projet";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment AND cp.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid";
$sql.= " WHERE d.entity IN (".getEntity('donation').")";
if (! empty($id))

View File

@ -182,7 +182,7 @@ class PaymentDonation extends CommonObject
$sql.= " pt.code as type_code, pt.libelle as type_libelle,";
$sql.= ' b.fk_account';
$sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id AND pt.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
$sql.= " WHERE t.rowid = ".$id;

View File

@ -1880,7 +1880,7 @@ else
$sql.= "c.code as p_code, c.libelle as payment_type,";
$sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id AND c.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id";
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid';
$sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
$sql.= " WHERE e.rowid = '".$id."'";

View File

@ -450,7 +450,7 @@ class ExpenseReport extends CommonObject
$sql.= " d.fk_statut as status, d.fk_c_paiement,";
$sql.= " dp.libelle as libelle_paiement, dp.code as code_paiement"; // INNER JOIN paiement
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id AND dp.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as dp ON d.fk_c_paiement = dp.id";
if ($ref) $sql.= " WHERE d.ref = '".$this->db->escape($ref)."'";
else $sql.= " WHERE d.rowid = ".$id;
//$sql.= $restrict;

View File

@ -166,7 +166,7 @@ class PaymentExpenseReport extends CommonObject
$sql.= " pt.code as type_code, pt.libelle as type_libelle,";
$sql.= ' b.fk_account';
$sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id AND pt.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
$sql.= " WHERE t.rowid = ".$id;

View File

@ -232,8 +232,8 @@ class CommandeFournisseur extends CommonOrder
$sql.= ', c.fk_incoterms, c.location_incoterms';
$sql.= ', i.libelle as libelle_incoterms';
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON c.fk_cond_reglement = cr.rowid AND cr.entity IN (".getEntity('c_payment_term').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON c.fk_mode_reglement = p.id AND p.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON c.fk_cond_reglement = cr.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON c.fk_mode_reglement = p.id";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
$sql.= " WHERE c.entity = ".$conf->entity;

View File

@ -561,8 +561,8 @@ class FactureFournisseur extends CommonInvoice
$sql.= ' t.fk_multicurrency, t.multicurrency_code, t.multicurrency_tx, t.multicurrency_total_ht, t.multicurrency_total_tva, t.multicurrency_total_ttc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON t.fk_cond_reglement = cr.rowid AND cr.entity IN (".getEntity('c_payment_term').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON t.fk_mode_reglement = p.id AND p.entity IN (".getEntity('c_paiement').")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON t.fk_cond_reglement = cr.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON t.fk_mode_reglement = p.id";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid';
if ($id) $sql.= " WHERE t.rowid=".$id;
if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."'";

View File

@ -80,7 +80,7 @@ class PaiementFourn extends Paiement
$sql.= ' c.code as paiement_code, c.libelle as paiement_type,';
$sql.= ' p.num_paiement, p.note, b.fk_account';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.getEntity('c_paiement').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid ';
$sql.= ' WHERE p.entity IN ('.getEntity('facture_fourn').')';
if ($id > 0)

View File

@ -2433,7 +2433,7 @@ else
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.getEntity('c_paiement').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
$sql.= ' WHERE pf.fk_facturefourn = '.$object->id;
$sql.= ' ORDER BY p.datep, p.tms';

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

@ -745,7 +745,7 @@ if (empty($action))
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id AND c.entity IN ('.getEntity('c_paiement').')';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';

View File

@ -3,7 +3,6 @@ sudo: false
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6

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

File diff suppressed because it is too large Load Diff

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

@ -1,43 +0,0 @@
<?php
namespace Stripe;
use Countable;
/**
* Class AttachedObject
*
* e.g. metadata on Stripe objects.
*
* @package Stripe
*/
class AttachedObject extends StripeObject implements Countable
{
/**
* 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;
}
}
/**
* Counts the number of elements in the AttachedObject instance.
*
* @return int the number of elements
*/
public function count()
{
return count($this->_values);
}
}

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
{
}

View File

@ -0,0 +1,10 @@
<?php
namespace Stripe\Error\OAuth;
/**
* InvalidScope is raised when an invalid scope parameter is provided.
*/
class InvalidScope extends OAuthBase
{
}

View File

@ -0,0 +1,23 @@
<?php
namespace Stripe\Error\OAuth;
class OAuthBase extends \Stripe\Error\Base
{
public function __construct(
$code,
$description,
$httpStatus = null,
$httpBody = null,
$jsonBody = null,
$httpHeaders = null
) {
parent::__construct($description, $httpStatus, $httpBody, $jsonBody, $httpHeaders);
$this->code = $code;
}
public function getErrorCode()
{
return $this->code;
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace Stripe\Error\OAuth;
/**
* UnsupportedGrantType is raised when an unuspported grant type
* parameter is specified.
*/
class UnsupportedGrantType extends OAuthBase
{
}

View File

@ -0,0 +1,11 @@
<?php
namespace Stripe\Error\OAuth;
/**
* UnsupportedResponseType is raised when an unsupported response type
* parameter is specified.
*/
class UnsupportedResponseType extends OAuthBase
{
}

View File

@ -0,0 +1,20 @@
<?php
namespace Stripe\Error;
class SignatureVerification extends Base
{
public function __construct(
$message,
$sigHeader,
$httpBody = null
) {
parent::__construct($message, null, $httpBody, null, null);
$this->sigHeader = $sigHeader;
}
public function getSigHeader()
{
return $this->sigHeader;
}
}

View File

@ -1,92 +0,0 @@
<?php
namespace Stripe;
/**
* Class ExternalAccount
*
* @property string $id
* @property string $object
*
* @package Stripe
*/
abstract class ExternalAccount extends ApiResource
{
/**
* @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()
{
$id = $this['id'];
if (!$id) {
$class = get_class($this);
$msg = "Could not determine which URL to request: $class instance "
. "has invalid ID: $id";
throw new Error\InvalidRequest($msg, null);
}
if ($this['customer']) {
$parent = $this['customer'];
$base = Customer::classUrl();
$path = 'sources';
} elseif ($this['account']) {
$parent = $this['account'];
$base = Account::classUrl();
$path = 'external_accounts';
} elseif ($this['recipient']) {
$parent = $this['recipient'];
$base = Recipient::classUrl();
$path = 'cards';
} else {
return null;
}
$parent = Util\Util::utf8($parent);
$id = Util\Util::utf8($id);
$parentExtn = urlencode($parent);
$extn = urlencode($id);
return "$base/$parentExtn/$path/$extn";
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return ExternalAccount The deleted external account.
*/
public function delete($params = null, $opts = null)
{
return $this->_delete($params, $opts);
}
/**
* @param array|string|null $opts
*
* @return ExternalAccount The saved external account.
*/
public function save($opts = null)
{
return $this->_save($opts);
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return ExternalAccount The verified (or not) external account.
*/
public function verify($params = null, $opts = null)
{
if ($this['customer']) {
$url = $this->instanceUrl() . '/verify';
list($response, $options) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $options);
return $this;
} else {
$message = 'Only customer external accounts can be verified in this manner.';
throw new Error\Api($message);
}
}
}

View File

@ -11,8 +11,8 @@ interface ClientInterface
* @param array $params KV pairs for parameters. Can be nested for arrays and hashes
* @param boolean $hasFile Whether or not $params references a file (via an @ prefix or
* CurlFile)
* @throws Error\Api & Error\ApiConnection
* @return array($rawBody, $httpStatusCode, $httpHeader)
* @throws \Stripe\Error\Api & \Stripe\Error\ApiConnection
* @return [$rawBody, $httpStatusCode, $httpHeader]
*/
public function request($method, $absUrl, $headers, $params, $hasFile);
}

View File

@ -36,6 +36,8 @@ class CurlClient implements ClientInterface
protected $defaultOptions;
protected $userAgentInfo;
/**
* CurlClient constructor.
*
@ -49,9 +51,20 @@ class CurlClient implements ClientInterface
*
* @param array|callable|null $defaultOptions
*/
public function __construct($defaultOptions = null)
public function __construct($defaultOptions = null, $randomGenerator = null)
{
$this->defaultOptions = $defaultOptions;
$this->randomGenerator = $randomGenerator ?: new Util\RandomGenerator();
$this->initUserAgentInfo();
}
public function initUserAgentInfo()
{
$curlVersion = curl_version();
$this->userAgentInfo = [
'httplib' => 'curl ' . $curlVersion['version'],
'ssllib' => $curlVersion['ssl_version'],
];
}
public function getDefaultOptions()
@ -59,6 +72,11 @@ class CurlClient implements ClientInterface
return $this->defaultOptions;
}
public function getUserAgentInfo()
{
return $this->userAgentInfo;
}
// USER DEFINED TIMEOUTS
const DEFAULT_TIMEOUT = 80;
@ -93,10 +111,9 @@ class CurlClient implements ClientInterface
public function request($method, $absUrl, $headers, $params, $hasFile)
{
$curl = curl_init();
$method = strtolower($method);
$opts = array();
$opts = [];
if (is_callable($this->defaultOptions)) { // call defaultOptions callback, set options to return value
$opts = call_user_func_array($this->defaultOptions, func_get_args());
if (!is_array($opts)) {
@ -114,24 +131,32 @@ class CurlClient implements ClientInterface
}
$opts[CURLOPT_HTTPGET] = 1;
if (count($params) > 0) {
$encoded = self::encode($params);
$encoded = Util\Util::urlEncode($params);
$absUrl = "$absUrl?$encoded";
}
} elseif ($method == 'post') {
$opts[CURLOPT_POST] = 1;
$opts[CURLOPT_POSTFIELDS] = $hasFile ? $params : self::encode($params);
$opts[CURLOPT_POSTFIELDS] = $hasFile ? $params : Util\Util::urlEncode($params);
} elseif ($method == 'delete') {
$opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
if (count($params) > 0) {
$encoded = self::encode($params);
$encoded = Util\Util::urlEncode($params);
$absUrl = "$absUrl?$encoded";
}
} else {
throw new Error\Api("Unrecognized method $method");
}
// It is only safe to retry network failures on POST requests if we
// add an Idempotency-Key header
if (($method == 'post') && (Stripe::$maxNetworkRetries > 0)) {
if (!isset($headers['Idempotency-Key'])) {
array_push($headers, 'Idempotency-Key: ' . $this->randomGenerator->uuid());
}
}
// Create a callback to capture HTTP headers for the response
$rheaders = array();
$rheaders = [];
$headerCallback = function ($curl, $header_line) use (&$rheaders) {
// Ignore the HTTP request line (HTTP/1.1 200 OK)
if (strpos($header_line, ":") === false) {
@ -163,50 +188,63 @@ class CurlClient implements ClientInterface
$opts[CURLOPT_TIMEOUT] = $this->timeout;
$opts[CURLOPT_HEADERFUNCTION] = $headerCallback;
$opts[CURLOPT_HTTPHEADER] = $headers;
if (!Stripe::$verifySslCerts) {
$opts[CURLOPT_CAINFO] = Stripe::getCABundlePath();
if (!Stripe::getVerifySslCerts()) {
$opts[CURLOPT_SSL_VERIFYPEER] = false;
}
curl_setopt_array($curl, $opts);
$rbody = curl_exec($curl);
list($rbody, $rcode) = $this->executeRequestWithRetries($opts, $absUrl);
if (!defined('CURLE_SSL_CACERT_BADFILE')) {
define('CURLE_SSL_CACERT_BADFILE', 77); // constant not defined in PHP
}
$errno = curl_errno($curl);
if ($errno == CURLE_SSL_CACERT ||
$errno == CURLE_SSL_PEER_CERTIFICATE ||
$errno == CURLE_SSL_CACERT_BADFILE
) {
array_push(
$headers,
'X-Stripe-Client-Info: {"ca":"using Stripe-supplied CA bundle"}'
);
$cert = self::caBundle();
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_CAINFO, $cert);
$rbody = curl_exec($curl);
}
if ($rbody === false) {
$errno = curl_errno($curl);
$message = curl_error($curl);
curl_close($curl);
$this->handleCurlError($absUrl, $errno, $message);
}
$rcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
return array($rbody, $rcode, $rheaders);
return [$rbody, $rcode, $rheaders];
}
/**
* @param number $errno
* @param array $opts cURL options
*/
private function executeRequestWithRetries($opts, $absUrl)
{
$numRetries = 0;
while (true) {
$rcode = 0;
$errno = 0;
$curl = curl_init();
curl_setopt_array($curl, $opts);
$rbody = curl_exec($curl);
if ($rbody === false) {
$errno = curl_errno($curl);
$message = curl_error($curl);
} else {
$rcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
}
curl_close($curl);
if ($this->shouldRetry($errno, $rcode, $numRetries)) {
$numRetries += 1;
$sleepSeconds = $this->sleepTime($numRetries);
usleep(intval($sleepSeconds * 1000000));
} else {
break;
}
}
if ($rbody === false) {
$this->handleCurlError($absUrl, $errno, $message, $numRetries);
}
return [$rbody, $rcode];
}
/**
* @param string $url
* @param int $errno
* @param string $message
* @param int $numRetries
* @throws Error\ApiConnection
*/
private function handleCurlError($url, $errno, $message)
private function handleCurlError($url, $errno, $message, $numRetries)
{
switch ($errno) {
case CURLE_COULDNT_CONNECT:
@ -231,52 +269,66 @@ class CurlClient implements ClientInterface
$msg .= " let us know at support@stripe.com.";
$msg .= "\n\n(Network error [errno $errno]: $message)";
if ($numRetries > 0) {
$msg .= "\n\nRequest was retried $numRetries times.";
}
throw new Error\ApiConnection($msg);
}
private static function caBundle()
/**
* Checks if an error is a problem that we should retry on. This includes both
* socket errors that may represent an intermittent problem and some special
* HTTP statuses.
* @param int $errno
* @param int $rcode
* @param int $numRetries
* @return bool
*/
private function shouldRetry($errno, $rcode, $numRetries)
{
return dirname(__FILE__) . '/../../data/ca-certificates.crt';
if ($numRetries >= Stripe::getMaxNetworkRetries()) {
return false;
}
// Retry on timeout-related problems (either on open or read).
if ($errno === CURLE_OPERATION_TIMEOUTED) {
return true;
}
// Destination refused the connection, the connection was reset, or a
// variety of other connection failures. This could occur from a single
// saturated server, so retry in case it's intermittent.
if ($errno === CURLE_COULDNT_CONNECT) {
return true;
}
// 409 conflict
if ($rcode === 409) {
return true;
}
return false;
}
/**
* @param array $arr An map of param keys to values.
* @param string|null $prefix
*
* Only public for testability, should not be called outside of CurlClient
*
* @return string A querystring, essentially.
*/
public static function encode($arr, $prefix = null)
private function sleepTime($numRetries)
{
if (!is_array($arr)) {
return $arr;
}
// Apply exponential backoff with $initialNetworkRetryDelay on the
// number of $numRetries so far as inputs. Do not allow the number to exceed
// $maxNetworkRetryDelay.
$sleepSeconds = min(
Stripe::getInitialNetworkRetryDelay() * 1.0 * pow(2, $numRetries - 1),
Stripe::getMaxNetworkRetryDelay()
);
$r = array();
foreach ($arr as $k => $v) {
if (is_null($v)) {
continue;
}
// Apply some jitter by randomizing the value in the range of
// ($sleepSeconds / 2) to ($sleepSeconds).
$sleepSeconds *= 0.5 * (1 + $this->randomGenerator->randFloat());
if ($prefix) {
if ($k !== null && (!is_int($k) || is_array($v))) {
$k = $prefix."[".$k."]";
} else {
$k = $prefix."[]";
}
}
// But never sleep less than the base sleep seconds.
$sleepSeconds = max(Stripe::getInitialNetworkRetryDelay(), $sleepSeconds);
if (is_array($v)) {
$enc = self::encode($v, $k);
if ($enc) {
$r[] = $enc;
}
} else {
$r[] = urlencode($k)."=".urlencode($v);
}
}
return implode("&", $r);
return $sleepSeconds;
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace Stripe;
// JsonSerializable only exists in PHP 5.4+. Stub if out if it doesn't exist
if (interface_exists('\JsonSerializable', false)) {
interface JsonSerializable extends \JsonSerializable
{
}
} else {
// PSR2 wants each interface to have its own file.
// @codingStandardsIgnoreStart
interface JsonSerializable
{
// @codingStandardsIgnoreEnd
public function jsonSerialize();
}
}

View File

@ -7,7 +7,7 @@ class AutoPagingIterator implements \Iterator
private $lastId = null;
private $page = null;
private $pageOffset = 0;
private $params = array();
private $params = [];
public function __construct($collection, $params)
{
@ -42,8 +42,8 @@ class AutoPagingIterator implements \Iterator
$this->pageOffset += count($this->page->data);
if ($this->page['has_more']) {
$this->params = array_merge(
$this->params ? $this->params : array(),
array('starting_after' => $this->lastId)
$this->params ?: [],
['starting_after' => $this->lastId]
);
$this->page = $this->page->all($this->params);
} else {

View File

@ -0,0 +1,18 @@
<?php
namespace Stripe\Util;
/**
* A very basic implementation of LoggerInterface that has just enough
* functionality that it can be the default for this library.
*/
class DefaultLogger implements LoggerInterface
{
public function error($message, array $context = [])
{
if (count($context) > 0) {
throw new \Exception('DefaultLogger does not currently implement context. Please implement if you need it.');
}
error_log($message);
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace Stripe\Util;
/**
* Describes a logger instance.
*
* This is a subset of the interface of the same name in the PSR-3 logger
* interface. We guarantee to keep it compatible, but we'd redefined it here so
* that we don't have to pull in the extra dependencies for users who don't want
* it.
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
* for the full interface specification.
*
* The message MUST be a string or object implementing __toString().
*
* The message MAY contain placeholders in the form: {foo} where foo
* will be replaced by the context data in key "foo".
*
* The context array can contain arbitrary data, the only assumption that
* can be made by implementors is that if an Exception instance is given
* to produce a stack trace, it MUST be in a key named "exception".
*/
interface LoggerInterface
{
/**
* Runtime errors that do not require immediate action but should typically
* be logged and monitored.
*
* @param string $message
* @param array $context
* @return null
*/
public function error($message, array $context = []);
}

View File

@ -0,0 +1,34 @@
<?php
namespace Stripe\Util;
/**
* A basic random generator. This is in a separate class so we the generator
* can be injected as a dependency and replaced with a mock in tests.
*/
class RandomGenerator
{
/**
* Returns a random value between 0 and $max.
*
* @param float $max (optional)
* @return float
*/
public function randFloat($max = 1.0)
{
return mt_rand() / mt_getrandmax() * $max;
}
/**
* Returns a v4 UUID.
*
* @return string
*/
public function uuid()
{
$arr = array_values(unpack('N1a/n4b/N1c', openssl_random_pseudo_bytes(16)));
$arr[2] = ($arr[2] & 0x0fff) | 0x4000;
$arr[3] = ($arr[3] & 0x3fff) | 0x8000;
return vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr);
}
}

View File

@ -6,10 +6,18 @@ use Stripe\Error;
class RequestOptions
{
/**
* @var array A list of headers that should be persisted across requests.
*/
public static $HEADERS_TO_PERSIST = [
'Stripe-Account',
'Stripe-Version',
];
public $headers;
public $apiKey;
public function __construct($key = null, $headers = array())
public function __construct($key = null, $headers = [])
{
$this->apiKey = $key;
$this->headers = $headers;
@ -32,6 +40,18 @@ class RequestOptions
return $other_options;
}
/**
* Discards all headers that we don't want to persist across requests.
*/
public function discardNonPersistentHeaders()
{
foreach ($this->headers as $k => $v) {
if (!in_array($k, self::$HEADERS_TO_PERSIST)) {
unset($this->headers[$k]);
}
}
}
/**
* Unpacks an options array into an RequestOptions object
* @param array|string|null $options a key => value array
@ -45,15 +65,15 @@ class RequestOptions
}
if (is_null($options)) {
return new RequestOptions(null, array());
return new RequestOptions(null, []);
}
if (is_string($options)) {
return new RequestOptions($options, array());
return new RequestOptions($options, []);
}
if (is_array($options)) {
$headers = array();
$headers = [];
$key = null;
if (array_key_exists('api_key', $options)) {
$key = $options['api_key'];

View File

@ -9,9 +9,9 @@ class Set implements IteratorAggregate
{
private $_elts;
public function __construct($members = array())
public function __construct($members = [])
{
$this->_elts = array();
$this->_elts = [];
foreach ($members as $item) {
$this->_elts[$item] = true;
}

View File

@ -7,24 +7,26 @@ use Stripe\StripeObject;
abstract class Util
{
private static $isMbstringAvailable = null;
private static $isHashEqualsAvailable = null;
/**
* Whether the provided array (or other) is a list rather than a dictionary.
* A list is defined as an array for which all the keys are consecutive
* integers starting at 0. Empty arrays are considered to be lists.
*
* @param array|mixed $array
* @return boolean True if the given object is a list.
* @return boolean true if the given object is a list.
*/
public static function isList($array)
{
if (!is_array($array)) {
return false;
}
// TODO: generally incorrect, but it's correct given Stripe's response
foreach (array_keys($array) as $k) {
if (!is_numeric($k)) {
return false;
}
if ($array === []) {
return true;
}
if (array_keys($array) !== range(0, count($array) - 1)) {
return false;
}
return true;
}
@ -37,7 +39,7 @@ abstract class Util
*/
public static function convertStripeObjectToArray($values)
{
$results = array();
$results = [];
foreach ($values as $k => $v) {
// FIXME: this is an encapsulation violation
if ($k[0] == '_') {
@ -63,26 +65,34 @@ abstract class Util
*/
public static function convertToStripeObject($resp, $opts)
{
$types = array(
$types = [
// data structures
'list' => 'Stripe\\Collection',
// business objects
'account' => 'Stripe\\Account',
'alipay_account' => 'Stripe\\AlipayAccount',
'apple_pay_domain' => 'Stripe\\ApplePayDomain',
'bank_account' => 'Stripe\\BankAccount',
'application_fee' => 'Stripe\\ApplicationFee',
'balance' => 'Stripe\\Balance',
'balance_transaction' => 'Stripe\\BalanceTransaction',
'bank_account' => 'Stripe\\BankAccount',
'bitcoin_receiver' => 'Stripe\\BitcoinReceiver',
'bitcoin_transaction' => 'Stripe\\BitcoinTransaction',
'card' => 'Stripe\\Card',
'charge' => 'Stripe\\Charge',
'country_spec' => 'Stripe\\CountrySpec',
'coupon' => 'Stripe\\Coupon',
'customer' => 'Stripe\\Customer',
'dispute' => 'Stripe\\Dispute',
'list' => 'Stripe\\Collection',
'ephemeral_key' => 'Stripe\\EphemeralKey',
'event' => 'Stripe\\Event',
'exchange_rate' => 'Stripe\\ExchangeRate',
'fee_refund' => 'Stripe\\ApplicationFeeRefund',
'file_upload' => 'Stripe\\FileUpload',
'invoice' => 'Stripe\\Invoice',
'invoiceitem' => 'Stripe\\InvoiceItem',
'event' => 'Stripe\\Event',
'file' => 'Stripe\\FileUpload',
'token' => 'Stripe\\Token',
'transfer' => 'Stripe\\Transfer',
'transfer_reversal' => 'Stripe\\TransferReversal',
'login_link' => 'Stripe\\LoginLink',
'order' => 'Stripe\\Order',
'order_return' => 'Stripe\\OrderReturn',
'payout' => 'Stripe\\Payout',
@ -93,15 +103,17 @@ abstract class Util
'refund' => 'Stripe\\Refund',
'sku' => 'Stripe\\SKU',
'source' => 'Stripe\\Source',
'source_transaction' => 'Stripe\\SourceTransaction',
'subscription' => 'Stripe\\Subscription',
'subscription_item' => 'Stripe\\SubscriptionItem',
'three_d_secure' => 'Stripe\\ThreeDSecure',
'fee_refund' => 'Stripe\\ApplicationFeeRefund',
'bitcoin_receiver' => 'Stripe\\BitcoinReceiver',
'bitcoin_transaction' => 'Stripe\\BitcoinTransaction',
);
'token' => 'Stripe\\Token',
'topup' => 'Stripe\\Topup',
'transfer' => 'Stripe\\Transfer',
'transfer_reversal' => 'Stripe\\TransferReversal',
];
if (self::isList($resp)) {
$mapped = array();
$mapped = [];
foreach ($resp as $i) {
array_push($mapped, self::convertToStripeObject($i, $opts));
}
@ -143,4 +155,84 @@ abstract class Util
return $value;
}
}
/**
* Compares two strings for equality. The time taken is independent of the
* number of characters that match.
*
* @param string $a one of the strings to compare.
* @param string $b the other string to compare.
* @return bool true if the strings are equal, false otherwise.
*/
public static function secureCompare($a, $b)
{
if (self::$isHashEqualsAvailable === null) {
self::$isHashEqualsAvailable = function_exists('hash_equals');
}
if (self::$isHashEqualsAvailable) {
return hash_equals($a, $b);
} else {
if (strlen($a) != strlen($b)) {
return false;
}
$result = 0;
for ($i = 0; $i < strlen($a); $i++) {
$result |= ord($a[$i]) ^ ord($b[$i]);
}
return ($result == 0);
}
}
/**
* @param array $arr A map of param keys to values.
* @param string|null $prefix
*
* @return string A querystring, essentially.
*/
public static function urlEncode($arr, $prefix = null)
{
if (!is_array($arr)) {
return $arr;
}
$r = [];
foreach ($arr as $k => $v) {
if (is_null($v)) {
continue;
}
if ($prefix) {
if ($k !== null && (!is_int($k) || is_array($v))) {
$k = $prefix."[".$k."]";
} else {
$k = $prefix."[]";
}
}
if (is_array($v)) {
$enc = self::urlEncode($v, $k);
if ($enc) {
$r[] = $enc;
}
} else {
$r[] = urlencode($k)."=".urlencode($v);
}
}
return implode("&", $r);
}
public static function normalizeId($id)
{
if (is_array($id)) {
$params = $id;
$id = $params['id'];
unset($params['id']);
} else {
$params = [];
}
return [$id, $params];
}
}

View File

@ -1,300 +0,0 @@
<?php
namespace Stripe;
class AccountTest extends TestCase
{
private function managedAccountResponse($id)
{
return array(
'id' => $id,
'currencies_supported' => array('usd', 'aed', 'afn', '...'),
'object' => 'account',
'business_name' => 'Stripe.com',
'bank_accounts' => array(
'object' => 'list',
'total_count' => 0,
'has_more' => false,
'url' => '/v1/accounts/' . $id . '/bank_accounts',
'data' => array()
),
'verification' => array(
'fields_needed' => array(
'product_description',
'business_url',
'support_phone',
'bank_account',
'tos_acceptance.ip',
'tos_acceptance.date'
),
'due_by' => null,
'contacted' => false
),
'tos_acceptance' => array(
'ip' => null,
'date' => null,
'user_agent' => null
),
'legal_entity' => array(
'type' => null,
'business_name' => null,
'address' => array(
'line1' => null,
'line2' => null,
'city' => null,
'state' => null,
'postal_code' => null,
'country' => 'US'
),
'first_name' => null,
'last_name' => null,
'additional_owners' => null,
'verification' => array(
'status' => 'unverified',
'document' => null,
'details' => null
)
)
);
}
private function deletedAccountResponse($id)
{
return array(
'id' => $id,
'deleted' => true
);
}
public function testBasicRetrieve()
{
$this->mockRequest('GET', '/v1/account', array(), $this->managedAccountResponse('acct_ABC'));
$account = Account::retrieve();
$this->assertSame($account->id, 'acct_ABC');
}
public function testIDRetrieve()
{
$this->mockRequest('GET', '/v1/accounts/acct_DEF', array(), $this->managedAccountResponse('acct_DEF'));
$account = Account::retrieve('acct_DEF');
$this->assertSame($account->id, 'acct_DEF');
}
public function testCreate()
{
$this->mockRequest(
'POST',
'/v1/accounts',
array('managed' => 'true'),
$this->managedAccountResponse('acct_ABC')
);
$account = Account::create(array(
'managed' => true
));
$this->assertSame($account->id, 'acct_ABC');
}
public function testDelete()
{
$account = self::createTestAccount();
$this->mockRequest(
'DELETE',
'/v1/accounts/' . $account->id,
array(),
$this->deletedAccountResponse('acct_ABC')
);
$deleted = $account->delete();
$this->assertSame($deleted->id, $account->id);
$this->assertTrue($deleted->deleted);
}
public function testReject()
{
$account = self::createTestAccount();
$this->mockRequest(
'POST',
'/v1/accounts/' . $account->id . '/reject',
array('reason' => 'fraud'),
$this->deletedAccountResponse('acct_ABC')
);
$rejected = $account->reject(array('reason' => 'fraud'));
$this->assertSame($rejected->id, $account->id);
}
public function testSaveLegalEntity()
{
$response = $this->managedAccountResponse('acct_ABC');
$this->mockRequest('POST', '/v1/accounts', array('managed' => 'true'), $response);
$response['legal_entity']['first_name'] = 'Bob';
$this->mockRequest(
'POST',
'/v1/accounts/acct_ABC',
array('legal_entity' => array('first_name' => 'Bob')),
$response
);
$account = Account::create(array('managed' => true));
$account->legal_entity->first_name = 'Bob';
$account->save();
$this->assertSame('Bob', $account->legal_entity->first_name);
}
public function testUpdateLegalEntity()
{
$response = $this->managedAccountResponse('acct_ABC');
$this->mockRequest('POST', '/v1/accounts', array('managed' => 'true'), $response);
$response['legal_entity']['first_name'] = 'Bob';
$this->mockRequest(
'POST',
'/v1/accounts/acct_ABC',
array('legal_entity' => array('first_name' => 'Bob')),
$response
);
$account = Account::create(array('managed' => true));
$account = Account::update($account['id'], array(
'legal_entity' => array(
'first_name' => 'Bob'
)
));
$this->assertSame('Bob', $account->legal_entity->first_name);
}
public function testCreateAdditionalOwners()
{
$request = array(
'managed' => true,
'country' => 'GB',
'legal_entity' => array(
'additional_owners' => array(
0 => array(
'dob' => array(
'day' => 12,
'month' => 5,
'year' => 1970,
),
'first_name' => 'xgvukvfrde',
'last_name' => 'rtcyvubhy',
),
1 => array(
'dob' => array(
'day' => 8,
'month' => 4,
'year' => 1979,
),
'first_name' => 'yutreuk',
'last_name' => 'dfcgvhbjihmv',
),
),
),
);
$acct = Account::create($request);
$response = $acct->__toArray(true);
$req_ao = $request['legal_entity']['additional_owners'];
$resp_ao = $response['legal_entity']['additional_owners'];
$this->assertSame($req_ao[0]['dob'], $resp_ao[0]['dob']);
$this->assertSame($req_ao[1]['dob'], $resp_ao[1]['dob']);
$this->assertSame($req_ao[0]['first_name'], $resp_ao[0]['first_name']);
$this->assertSame($req_ao[1]['first_name'], $resp_ao[1]['first_name']);
}
public function testUpdateAdditionalOwners()
{
$response = $this->managedAccountResponse('acct_ABC');
$this->mockRequest('POST', '/v1/accounts', array('managed' => 'true'), $response);
$response['legal_entity']['additional_owners'] = array(array(
'first_name' => 'Bob',
'last_name' => null,
'address' => array(
'line1' => null,
'line2' => null,
'city' => null,
'state' => null,
'postal_code' => null,
'country' => null
),
'verification' => array(
'status' => 'unverified',
'document' => null,
'details' => null
)
));
$this->mockRequest(
'POST',
'/v1/accounts/acct_ABC',
array('legal_entity' => array('additional_owners' => array(array('first_name' => 'Bob')))),
$response
);
$response['legal_entity']['additional_owners'][0]['last_name'] = 'Smith';
$this->mockRequest(
'POST',
'/v1/accounts/acct_ABC',
array('legal_entity' => array('additional_owners' => array(array('last_name' => 'Smith')))),
$response
);
$response['legal_entity']['additional_owners'][0]['last_name'] = 'Johnson';
$this->mockRequest(
'POST',
'/v1/accounts/acct_ABC',
array('legal_entity' => array('additional_owners' => array(array('last_name' => 'Johnson')))),
$response
);
$response['legal_entity']['additional_owners'][0]['verification']['document'] = 'file_123';
$this->mockRequest(
'POST',
'/v1/accounts/acct_ABC',
array('legal_entity' => array('additional_owners' => array(array('verification' => array('document' => 'file_123'))))),
$response
);
$response['legal_entity']['additional_owners'][1] = array(
'first_name' => 'Jane',
'last_name' => 'Doe'
);
$this->mockRequest(
'POST',
'/v1/accounts/acct_ABC',
array('legal_entity' => array('additional_owners' => array(1 => array('first_name' => 'Jane')))),
$response
);
$account = Account::create(array('managed' => true));
$account->legal_entity->additional_owners = array(array('first_name' => 'Bob'));
$account->save();
$this->assertSame(1, count($account->legal_entity->additional_owners));
$this->assertSame('Bob', $account->legal_entity->additional_owners[0]->first_name);
$account->legal_entity->additional_owners[0]->last_name = 'Smith';
$account->save();
$this->assertSame(1, count($account->legal_entity->additional_owners));
$this->assertSame('Smith', $account->legal_entity->additional_owners[0]->last_name);
$account['legal_entity']['additional_owners'][0]['last_name'] = 'Johnson';
$account->save();
$this->assertSame(1, count($account->legal_entity->additional_owners));
$this->assertSame('Johnson', $account->legal_entity->additional_owners[0]->last_name);
$account->legal_entity->additional_owners[0]->verification->document = 'file_123';
$account->save();
$this->assertSame('file_123', $account->legal_entity->additional_owners[0]->verification->document);
$account->legal_entity->additional_owners[1] = array('first_name' => 'Jane');
$account->save();
$this->assertSame('Jane', $account->legal_entity->additional_owners[1]->first_name);
}
}

View File

@ -1,68 +0,0 @@
<?php
namespace Stripe;
use Stripe\HttpClient\CurlClient;
class ApiRequestorTest extends TestCase
{
public function testEncodeObjects()
{
$reflector = new \ReflectionClass('Stripe\\ApiRequestor');
$method = $reflector->getMethod('_encodeObjects');
$method->setAccessible(true);
$a = array('customer' => new Customer('abcd'));
$enc = $method->invoke(null, $a);
$this->assertSame($enc, array('customer' => 'abcd'));
// Preserves UTF-8
$v = array('customer' => "");
$enc = $method->invoke(null, $v);
$this->assertSame($enc, $v);
// Encodes latin-1 -> UTF-8
$v = array('customer' => "\xe9");
$enc = $method->invoke(null, $v);
$this->assertSame($enc, array('customer' => "\xc3\xa9"));
}
public function testHttpClientInjection()
{
$reflector = new \ReflectionClass('Stripe\\ApiRequestor');
$method = $reflector->getMethod('httpClient');
$method->setAccessible(true);
$curl = new CurlClient();
$curl->setTimeout(10);
ApiRequestor::setHttpClient($curl);
$injectedCurl = $method->invoke(new ApiRequestor());
$this->assertSame($injectedCurl, $curl);
}
public function testDefaultHeaders()
{
$reflector = new \ReflectionClass('Stripe\\ApiRequestor');
$method = $reflector->getMethod('_defaultHeaders');
$method->setAccessible(true);
// no way to stub static methods with PHPUnit 4.x :(
Stripe::setAppInfo('MyTestApp', '1.2.34', 'https://mytestapp.example');
$apiKey = 'sk_test_notarealkey';
$headers = $method->invoke(null, $apiKey);
$ua = json_decode($headers['X-Stripe-Client-User-Agent']);
$this->assertSame($ua->application->name, 'MyTestApp');
$this->assertSame($ua->application->version, '1.2.34');
$this->assertSame($ua->application->url, 'https://mytestapp.example');
$this->assertSame(
$headers['User-Agent'],
'Stripe/v1 PhpBindings/' . Stripe::VERSION . ' MyTestApp/1.2.34 (https://mytestapp.example)'
);
$this->assertSame($headers['Authorization'], 'Bearer ' . $apiKey);
}
}

View File

@ -1,72 +0,0 @@
<?php
namespace Stripe;
class ApplePayDomainTest extends TestCase
{
public function testCreation()
{
$this->mockRequest(
'POST',
'/v1/apple_pay/domains',
array('domain_name' => 'test.com'),
array(
'id' => 'apwc_create',
'object' => 'apple_pay_domain'
)
);
$d = ApplePayDomain::create(array(
'domain_name' => 'test.com'
));
$this->assertSame('apwc_create', $d->id);
$this->assertInstanceOf('Stripe\\ApplePayDomain', $d);
}
public function testRetrieve()
{
$this->mockRequest(
'GET',
'/v1/apple_pay/domains/apwc_retrieve',
array(),
array(
'id' => 'apwc_retrieve',
'object' => 'apple_pay_domain'
)
);
$d = ApplePayDomain::retrieve('apwc_retrieve');
$this->assertSame('apwc_retrieve', $d->id);
$this->assertInstanceOf('Stripe\\ApplePayDomain', $d);
}
public function testDeletion()
{
self::authorizeFromEnv();
$d = ApplePayDomain::create(array(
'domain_name' => 'jackshack.website'
));
$this->assertInstanceOf('Stripe\\ApplePayDomain', $d);
$this->mockRequest(
'DELETE',
'/v1/apple_pay/domains/' . $d->id,
array(),
array('deleted' => true)
);
$d->delete();
$this->assertTrue($d->deleted);
}
public function testList()
{
$this->mockRequest(
'GET',
'/v1/apple_pay/domains',
array(),
array(
'url' => '/v1/apple_pay/domains',
'object' => 'list'
)
);
$all = ApplePayDomain::all();
$this->assertSame($all->url, '/v1/apple_pay/domains');
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace Stripe;
class ApplicationFeeRefundTest extends TestCase
{
public function testUrls()
{
$refund = new ApplicationFeeRefund();
$refund->id = 'refund_id';
$refund->fee = 'fee_id';
$this->assertSame(
$refund->instanceUrl(),
'/v1/application_fees/fee_id/refunds/refund_id'
);
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace Stripe;
class ApplicationFeeTest extends TestCase
{
public function testUrls()
{
$applicationFee = new ApplicationFee('abcd/efgh');
$this->assertSame(
$applicationFee->instanceUrl(),
'/v1/application_fees/abcd%2Fefgh'
);
}
public function testList()
{
self::authorizeFromEnv();
$d = ApplicationFee::all();
$this->assertSame($d->url, '/v1/application_fees');
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace Stripe;
class AuthenticationErrorTest extends TestCase
{
public function testInvalidCredentials()
{
Stripe::setApiKey('invalid');
try {
Customer::create();
} catch (Error\Authentication $e) {
$this->assertSame(401, $e->getHttpStatus());
}
}
}

View File

@ -1,15 +0,0 @@
<?php
namespace Stripe;
class BalanceTest extends TestCase
{
public function testRetrieve()
{
self::authorizeFromEnv();
$d = Balance::retrieve();
$this->assertSame($d->object, "balance");
$this->assertTrue(Util\Util::isList($d->available));
$this->assertTrue(Util\Util::isList($d->pending));
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Stripe;
class BalanceTransactionTest extends TestCase
{
public function testList()
{
self::authorizeFromEnv();
$d = BalanceTransaction::all();
$this->assertSame($d->url, '/v1/balance/history');
}
}

View File

@ -1,32 +0,0 @@
<?php
namespace Stripe;
class BankAccountTest extends TestCase
{
public function testVerify()
{
self::authorizeFromEnv();
$customer = self::createTestCustomer();
$bankAccount = $customer->sources->create(array(
'source' => array(
'object' => 'bank_account',
'account_holder_type' => 'individual',
'account_number' => '000123456789',
'account_holder_name' => 'John Doe',
'routing_number' => '110000000',
'country' => 'US'
)
));
$this->assertSame($bankAccount->status, 'new');
$bankAccount = $bankAccount->verify(array(
'amounts' => array(32, 45)
));
$this->assertSame($bankAccount->status, 'verified');
}
}

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