diff --git a/htdocs/stripe/class/actions_stripe.class.php b/htdocs/stripe/class/actions_stripe.class.php index 513999854e824..a03630f5920c4 100644 --- a/htdocs/stripe/class/actions_stripe.class.php +++ b/htdocs/stripe/class/actions_stripe.class.php @@ -19,16 +19,18 @@ */ /** - * \file htdocs/multicompany/actions_multicompany.class.php - * \ingroup multicompany - * \brief File Class multicompany + * \file htdocs/stripe/class/actions_stripe.class.php + * \ingroup stripe + * \brief File Class actionsstripeconnect */ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';; + + $langs->load("stripe@stripe"); + /** - * \class ActionsMulticompany - * \brief Class Actions of the module multicompany + * Class Actions Stripe Connect */ class ActionsStripeconnect { @@ -54,21 +56,25 @@ function __construct($db) /** - * + * formObjectOptions + * + * @param array $parameters Parameters + * @param Object $object Object + * @param string $action Action */ function formObjectOptions($parameters=false, &$object, &$action='') { global $db,$conf,$user,$langs,$form; - if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha'))) -{ - $service = 'StripeTest'; - dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning'); -} -else -{ - $service = 'StripeLive'; -} + if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha'))) + { + $service = 'StripeTest'; + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning'); + } + else + { + $service = 'StripeLive'; + } if (is_array($parameters) && ! empty($parameters)) { @@ -80,88 +86,96 @@ function formObjectOptions($parameters=false, &$object, &$action='') if (is_object($object) && $object->element == 'societe') - { - $this->resprints.= ''; - $this->resprints.= '
'; - $this->resprints.= $langs->trans('StripeCustomer'); - $this->resprints.= ''; -// $this->resprints.= ''.img_edit().''; - $this->resprints.= '
'; - $this->resprints.= ''; - $this->resprints.= ''; - $stripe=new Stripe($db); -if ($stripe->getStripeAccount($service)&&$object->client!=0) { -$customer=$stripe->customerStripe($object->id,$stripe->getStripeAccount($service)); -$this->resprints.= $customer->id; -} -else { -$this->resprints.= $langs->trans("NoStripe"); -} - $this->resprints.= ''; - - } - elseif (is_object($object) && $object->element == 'member'){ - $this->resprints.= ''; - $this->resprints.= '
'; - $this->resprints.= $langs->trans('StripeCustomer'); - $this->resprints.= ''; - $this->resprints.= '
'; - $this->resprints.= ''; - $this->resprints.= ''; - $stripe=new Stripe($db); -if ($stripe->getStripeAccount($service)&&$object->fk_soc>'0') { -$customer=$stripe->customerStripe($object->fk_soc,$stripe->getStripeAccount($service)); -$this->resprints.= $customer->id; -} -else { -$this->resprints.= $langs->trans("NoStripe"); -} - $this->resprints.= ''; - - $this->resprints.= ''; - $this->resprints.= '
'; - $this->resprints.= $langs->trans('SubscriptionStripe'); - $this->resprints.= ''; - $this->resprints.= '
'; - $this->resprints.= ''; - $this->resprints.= ''; - $stripe=new Stripe($db); -if (7==4) { -$customer=$stripe->customerStripe($object->id,$stripe->getStripeAccount($service)); -$this->resprints.= $customer->id; -} -else { -$this->resprints.= $langs->trans("NoStripe"); -} - $this->resprints.= ''; - } - elseif (is_object($object) && $object->element == 'adherent_type'){ - $this->resprints.= ''; - $this->resprints.= '
'; - $this->resprints.= $langs->trans('PlanStripe'); - $this->resprints.= ''; -// $this->resprints.= ''.img_edit().''; - $this->resprints.= '
'; - $this->resprints.= ''; - $this->resprints.= ''; - $stripe=new Stripe($db); -if (7==4) { -$customer=$stripe->customerStripe($object->id,$stripe->getStripeAccount($service)); -$this->resprints.= $customer->id; -} -else { -$this->resprints.= $langs->trans("NoStripe"); -} - $this->resprints.= ''; - } + { + $this->resprints.= ''; + $this->resprints.= '
'; + $this->resprints.= $langs->trans('StripeCustomer'); + $this->resprints.= ''; + // $this->resprints.= ''.img_edit().''; + $this->resprints.= '
'; + $this->resprints.= ''; + $this->resprints.= ''; + $stripe=new Stripe($db); + if ($stripe->getStripeAccount($service)&&$object->client!=0) { + $customer=$stripe->customerStripe($object->id,$stripe->getStripeAccount($service)); + $this->resprints.= $customer->id; + } + else { + $this->resprints.= $langs->trans("NoStripe"); + } + $this->resprints.= ''; + + } + elseif (is_object($object) && $object->element == 'member'){ + $this->resprints.= ''; + $this->resprints.= '
'; + $this->resprints.= $langs->trans('StripeCustomer'); + $this->resprints.= ''; + $this->resprints.= '
'; + $this->resprints.= ''; + $this->resprints.= ''; + $stripe=new Stripe($db); + if ($stripe->getStripeAccount($service)&&$object->fk_soc>'0') { + $customer=$stripe->customerStripe($object->fk_soc,$stripe->getStripeAccount($service)); + $this->resprints.= $customer->id; + } + else { + $this->resprints.= $langs->trans("NoStripe"); + } + $this->resprints.= ''; + + $this->resprints.= ''; + $this->resprints.= '
'; + $this->resprints.= $langs->trans('SubscriptionStripe'); + $this->resprints.= ''; + $this->resprints.= '
'; + $this->resprints.= ''; + $this->resprints.= ''; + $stripe=new Stripe($db); + if (7==4) { + $customer=$stripe->customerStripe($object->id,$stripe->getStripeAccount($service)); + $this->resprints.= $customer->id; + } + else { + $this->resprints.= $langs->trans("NoStripe"); + } + $this->resprints.= ''; + } + elseif (is_object($object) && $object->element == 'adherent_type'){ + $this->resprints.= ''; + $this->resprints.= '
'; + $this->resprints.= $langs->trans('PlanStripe'); + $this->resprints.= ''; + // $this->resprints.= ''.img_edit().''; + $this->resprints.= '
'; + $this->resprints.= ''; + $this->resprints.= ''; + $stripe=new Stripe($db); + if (7==4) { + $customer=$stripe->customerStripe($object->id,$stripe->getStripeAccount($service)); + $this->resprints.= $customer->id; + } + else { + $this->resprints.= $langs->trans("NoStripe"); + } + $this->resprints.= ''; + } return 0; } - - function addMoreActionsButtons($parameters=false, &$object, &$action='') + + /** + * addMoreActionsButtons + * + * @param arra $parameters Parameters + * @param Object $object Object + * @param string $action action + * @return int 0 + */ + function addMoreActionsButtons($parameters=false, &$object, &$action='') { global $db,$conf,$user,$langs,$form; - if (is_object($object) && $object->element == 'facture'){ - // On verifie si la facture a des paiements + if (is_object($object) && $object->element == 'facture'){ + // On verifie si la facture a des paiements $sql = 'SELECT pf.amount'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf'; $sql .= ' WHERE pf.fk_facture = ' . $object->id; @@ -183,34 +197,35 @@ function addMoreActionsButtons($parameters=false, &$object, &$action='') $resteapayer = $object->total_ttc - $totalpaye; // Request a direct debit order if ($object->statut > Facture::STATUS_DRAFT && $object->statut < Facture::STATUS_ABANDONED && $object->paye == 0) - { $stripe=new Stripe($db); - if ($resteapayer > 0) - { - if ($stripe->getStripeAccount($conf->entity)) // a modifier avec droit stripe - { - $langs->load("withdrawals"); - print ''.$langs->trans("StripeConnectPay").''; - } - else - { - print ''.$langs->trans("StripeConnectPay").''; - } - } - elseif ($resteapayer == 0) - { - print ''.$langs->trans("StripeConnectPay").''; - } + { + $stripe=new Stripe($db); + if ($resteapayer > 0) + { + if ($stripe->getStripeAccount($conf->entity)) // a modifier avec droit stripe + { + $langs->load("withdrawals"); + print ''.$langs->trans("StripeConnectPay").''; + } + else + { + print ''.$langs->trans("StripeConnectPay").''; + } + } + elseif ($resteapayer == 0) + { + print ''.$langs->trans("StripeConnectPay").''; + } } - else { - print ''.$langs->trans("StripeConnectPay").''; - } - } - elseif (is_object($object) && $object->element == 'invoice_supplier'){ -print ''.$langs->trans("StripeConnectPay").''; - } - elseif (is_object($object) && $object->element == 'member'){ -print ''.$langs->trans("StripeAutoSubscription").''; - } + else { + print ''.$langs->trans("StripeConnectPay").''; + } + } + elseif (is_object($object) && $object->element == 'invoice_supplier'){ + print ''.$langs->trans("StripeConnectPay").''; + } + elseif (is_object($object) && $object->element == 'member'){ + print ''.$langs->trans("StripeAutoSubscription").''; + } return 0; }