diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 620a7786310..7612e7b261a 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -177,6 +177,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } + if (! GETPOST('label','alpha')) + { + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + $ok=0; + } // Clean some parameters if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null @@ -208,7 +213,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert)) $sql.= $tabrowid[$id].","; $sql.= $tabfieldinsert[$id]; - $sql.=",active)"; + $sql.=",active,entity)"; $sql.= " VALUES("; // List of values @@ -221,11 +226,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $_POST[$listfieldvalue[$i]] = $conf->entity; } if ($i) $sql.=","; - if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' + if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $i++; } - $sql.=",1)"; + $sql.=",1,".$conf->entity.")"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); @@ -275,6 +280,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; + $sql.=" AND entity = ".$conf->entity; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; @@ -298,6 +304,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete else { $rowidcol="rowid"; } $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'"; + $sql.=" AND entity = ".$conf->entity; dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); @@ -326,6 +333,7 @@ if ($action == $acts[0]) elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'"; } + $sql.=" AND entity = ".$conf->entity; $result = $db->query($sql); if (!$result) @@ -346,6 +354,7 @@ if ($action == $acts[1]) elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'"; } + $sql.=" AND entity = ".$conf->entity; $result = $db->query($sql); if (!$result) @@ -389,13 +398,7 @@ if ($id) { // Complete requete recherche valeurs avec critere de tri $sql=$tabsql[$id]; - - if ($search_country_id > 0) - { - if (preg_match('/ WHERE /',$sql)) $sql.= " AND "; - else $sql.=" WHERE "; - $sql.= " c.rowid = ".$search_country_id; - } + $sql.= " WHERE a.entity = ".$conf->entity; if ($sortfield) { @@ -416,7 +419,6 @@ if ($id) } $sql.=$tabsqlsort[$id]; $sql.=$db->plimit($listlimit+1,$offset); - //print $sql; $fieldlist=explode(',',$tabfield[$id]); diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index f67956c1a74..3bbbaa5faca 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -455,6 +455,7 @@ if (! $error && $action == 'writebookkeeping') { // No subledger_account value for the bank line but add a specific label_operation $bookkeeping->subledger_account = ''; $bookkeeping->label_operation = $reflabel; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -561,8 +562,8 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->label_compte = ''; } } - $bookkeeping->label_operation = $reflabel; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -608,8 +609,8 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_create = $now; $bookkeeping->label_compte = ''; - $bookkeeping->label_operation = $reflabel; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 2b5aa063887..265628eb35a 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -216,6 +216,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -265,6 +266,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -320,6 +322,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index ec21937c8ff..27f4521de4b 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -318,6 +318,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -371,6 +372,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -430,6 +432,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -482,6 +485,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 5088841b3d1..c10cc2b311f 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -121,6 +121,7 @@ if ($in_bookkeeping == 'notyet') // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account } $sql .= " ORDER BY f.datef"; +//print $sql; dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG); $result = $db->query($sql); @@ -319,6 +320,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -372,6 +374,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; @@ -430,6 +433,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; $totaldebit += $bookkeeping->debit; $totalcredit += $bookkeeping->credit; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 65f9c65e641..250c8e18b4e 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1822,7 +1822,7 @@ else // Presend form $modelmail='member'; - $defaulttopic='SendMemberRef'; + $defaulttopic='CardContent'; $diroutput = $conf->adherent->dir_output; $trackid = 'mem'.$object->id; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 5691cd6687b..78fc662f6b4 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1248,9 +1248,9 @@ class Adherent extends CommonObject * Insert subscription into database and eventually add links to banks, mailman, etc... * * @param int $date Date of effect of subscription - * @param double $montant Amount of subscription (0 accepted for some members) + * @param double $amount Amount of subscription (0 accepted for some members) * @param int $accountid Id bank account - * @param string $operation Type operation (if Id bank account provided) + * @param string $operation Type of payment (if Id bank account provided). Example: 'CB', ... * @param string $label Label operation (if Id bank account provided) * @param string $num_chq Numero cheque (if Id bank account provided) * @param string $emetteur_nom Name of cheque writer @@ -1258,7 +1258,7 @@ class Adherent extends CommonObject * @param int $datesubend Date end subscription * @return int rowid of record added, <0 if KO */ - function subscription($date, $montant, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0) + function subscription($date, $amount, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0) { global $conf,$langs,$user; @@ -1267,7 +1267,7 @@ class Adherent extends CommonObject $error=0; // Clean parameters - if (! $montant) $montant=0; + if (! $amount) $amount=0; $this->db->begin(); @@ -1287,8 +1287,9 @@ class Adherent extends CommonObject $subscription->fk_adherent=$this->id; $subscription->dateh=$date; // Date of new subscription $subscription->datef=$datefin; // End data of new subscription - $subscription->amount=$montant; - $subscription->note=$label; + $subscription->amount=$amount; + $subscription->note=$label; // deprecated + $subscription->note_public=$label; $rowid=$subscription->create($user); if ($rowid > 0) @@ -1300,7 +1301,7 @@ class Adherent extends CommonObject { // Change properties of object (used by triggers) $this->last_subscription_date=dol_now(); - $this->last_subscription_amount=$montant; + $this->last_subscription_amount=$amount; $this->last_subscription_date_start=$date; $this->last_subscription_date_end=$datefin; } @@ -1319,11 +1320,303 @@ class Adherent extends CommonObject else { $this->error=$subscription->error; + $this->errors=$subscription->errors; $this->db->rollback(); return -1; } } + + /** + * 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 string $autocreatethirdparty Auto create new thirdparty if member not linked to a thirdparty. + * @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) + { + global $conf, $langs, $user, $mysoc; + + $error = 0; + + // Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect' + if ($option == 'bankdirect' && $accountid) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $acct=new Account($this->db); + $result=$acct->fetch($accountid); + + $dateop=$paymentdate; + + $insertid=$acct->addline($dateop, $operation, $label, $amount, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); + if ($insertid > 0) + { + $inserturlid=$acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); + if ($inserturlid > 0) + { + // Update table subscription + $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; + $sql.=" WHERE rowid=".$subscriptionid; + + dol_syslog("subscription::subscription", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + $error++; + $this->error=$this->db->lasterror(); + $this->errors[]=$this->error; + } + } + else + { + $error++; + $this->error=$acct->error; + $this->errors=$acct->errors; + } + } + else + { + $error++; + $this->error=$acct->error; + $this->errors=$acct->errors; + } + } + + // If option choosed, we create invoice + if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly') + { + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; + + $invoice=new Facture($this->db); + $customer=new Societe($this->db); + + if (! $error) + { + if (! ($this->fk_soc > 0)) + { + if ($autocreatethirdparty) + { + // Create a linked thirdparty to member + $companyalias=''; + $fullname = $this->getFullName($langs); + + if ($this->morphy == 'mor') + { + $companyname=$this->societe; + if (! empty($fullname)) $companyalias=$fullname; + } + else + { + $companyname=$fullname; + if (! empty($this->societe)) $companyalias=$this->societe; + } + + $result=$customer->create_from_member($this, $companyname, $companyalias); + if ($result < 0) + { + $this->error = $company->error; + $this->errors = $company->errors; + $error++; + } + else + { + $this->fk_soc = $result; + } + } + else + { + $langs->load("errors"); + $this->error=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); + $this->errors[]=$this->error; + $error++; + } + } + } + if (! $error) + { + $result=$customer->fetch($this->fk_soc); + if ($result <= 0) + { + $this->error=$customer->error; + $this->errors=$customer->errors; + $error++; + } + } + + if (! $error) + { + // Create draft invoice + $invoice->type=Facture::TYPE_STANDARD; + $invoice->cond_reglement_id=$customer->cond_reglement_id; + if (empty($invoice->cond_reglement_id)) + { + $paymenttermstatic=new PaymentTerm($this->db); + $invoice->cond_reglement_id=$paymenttermstatic->getDefaultId(); + if (empty($invoice->cond_reglement_id)) + { + $error++; + $this->error='ErrorNoPaymentTermRECEPFound'; + $this->errors[]=$this->error; + } + } + $invoice->socid=$this->fk_soc; + $invoice->date=$datesubscription; + + // Possibility to add external linked objects with hooks + $invoice->linked_objects['subscription'] = $subscriptionid; + if (! empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects'])) + { + $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']); + } + + $result=$invoice->create($user); + if ($result <= 0) + { + $this->error=$invoice->error; + $this->errors=$invoice->errors; + $error++; + } + } + + if (! $error) + { + // Add line to draft invoice + $idprodsubscription=0; + if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS; + + $vattouse=0; + if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') + { + $vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription); + } + //print xx".$vattouse." - ".$mysoc." - ".$customer;exit; + $result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datesubscription,$datesubend,0,0,'','TTC',$amount,1); + if ($result <= 0) + { + $this->error=$invoice->error; + $this->errors=$invoice->errors; + $error++; + } + } + + if (! $error) + { + // Validate invoice + $result=$invoice->validate($user); + if ($result <= 0) + { + $this->error=$invoice->error; + $this->errors=$invoice->errors; + $error++; + } + } + + // Add payment onto invoice + if (! $error && $option == 'bankviainvoice' && $accountid) + { + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; + + $amounts = array(); + $amounts[$invoice->id] = price2num($amount); + + $paiement = new Paiement($this->db); + $paiement->datepaye = $paymentdate; + $paiement->amounts = $amounts; + $paiement->paiementid = dol_getIdFromCode($this->db,$operation,'c_paiement','code','id',1); + $paiement->num_paiement = $num_chq; + $paiement->note = $label; + $paiement->note_public = $label; + + if (! $error) + { + // Create payment line for invoice + $paiement_id = $paiement->create($user); + if (! $paiement_id > 0) + { + $this->error=$paiement->error; + $this->errors=$paiement->errors; + $error++; + } + } + + if (! $error) + { + // Add transaction into bank account + $bank_line_id=$paiement->addPaymentToBank($user,'payment','(SubscriptionPayment)',$accountid,$emetteur_nom,$emetteur_banque); + if (! ($bank_line_id > 0)) + { + $this->error=$paiement->error; + $this->errors=$paiement->errors; + $error++; + } + } + + if (! $error) + { + // Update fk_bank into subscription table + $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id; + $sql.= ' WHERE rowid='.$subscriptionid; + + $result = $this->db->query($sql); + if (! $result) + { + $error++; + } + } + + if (! $error) + { + // 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) + { + return -1; + } + else + { + return 1; + } + } + + /** * Function that validate a member * @@ -2155,9 +2448,9 @@ class Adherent extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id * @return bool */ public static function replaceThirdparty($db, $origin_id, $dest_id) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 8d4b1884bab..1c4007780b9 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -77,15 +77,17 @@ class Subscription extends CommonObject $this->error=$langs->trans("ErrorBadValueForDate"); return -1; } + if (empty($this->datec)) $this->datec = $now; + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, datec, dateadh, datef, subscription, note)"; - $sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate($now)."',"; + $sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate($this->datec)."',"; $sql.= " '".$this->db->idate($this->dateh)."',"; $sql.= " '".$this->db->idate($this->datef)."',"; $sql.= " ".$this->amount.","; - $sql.= " '".$this->db->escape($this->note)."')"; + $sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')"; $resql = $this->db->query($sql); if (! $resql) { @@ -324,6 +326,8 @@ class Subscription extends CommonObject global $langs; $result=''; + + $langs->load("members"); $label=$langs->trans("ShowSubscription").': '.$this->ref; $linkstart = ''; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8d4b7829925..3b200ed526c 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -118,7 +118,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights { if ($result > 0) { - // Creation user + // Creation of thirdparty $company = new Societe($db); $result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); @@ -203,8 +203,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $langs->load("banks"); - $result=$object->fetch($rowid); - $result=$adht->fetch($object->typeid); + $result = $object->fetch($rowid); + $result = $adht->fetch($object->typeid); // Subscription informations $datesubscription=0; @@ -222,7 +222,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); } - $subscription=price2num(GETPOST("subscription",'alpha')); // Amount of subscription + $amount=price2num(GETPOST("subscription",'alpha')); // Amount of subscription $label=$_POST["label"]; // Payment informations @@ -233,6 +233,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $emetteur_banque=$_POST["chqbank"]; $option=$_POST["paymentsave"]; if (empty($option)) $option='none'; + $sendalsoemail=GETPOST("sendmail",'alpha'); // Check parameters if (! $datesubscription) @@ -263,8 +264,6 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $action='addsubscription'; } - $amount = price2num(GETPOST("subscription",'alpha')); - // Check if a payment is mandatory or not if (! $error && $adht->subscription) // Member type need subscriptions { @@ -284,7 +283,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { if (! $_POST["label"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")); if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["operation"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); - if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["accountid"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("FinancialAccount")); + if ($_POST["paymentsave"] != 'invoiceonly' && ! ($_POST["accountid"] > 0)) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("FinancialAccount")); } else { @@ -292,19 +291,22 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! } if ($errmsg) { + $error++; setEventMessages($errmsg, null, 'errors'); + $error++; $action='addsubscription'; } } } } + // Record the subscription then complementary actions if (! $error && $action=='subscription') { $db->begin(); // Create subscription - $crowid=$object->subscription($datesubscription, $subscription, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); + $crowid=$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); if ($crowid <= 0) { $error++; @@ -314,233 +316,12 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if (! $error) { - // Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect' - if ($option == 'bankdirect' && $accountid) - { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - - $acct=new Account($db); - $result=$acct->fetch($accountid); - - $dateop=$paymentdate; - - $insertid=$acct->addline($dateop, $operation, $label, $subscription, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); - if ($insertid > 0) - { - $inserturlid=$acct->add_url_line($insertid, $object->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $object->getFullname($langs), 'member'); - if ($inserturlid > 0) - { - // Update table subscription - $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; - $sql.=" WHERE rowid=".$crowid; - - dol_syslog("subscription::subscription", LOG_DEBUG); - $resql = $db->query($sql); - if (! $resql) - { - $error++; - $errmsg=$db->lasterror(); - setEventMessages($errmsg, null, 'errors'); - } - } - else - { - $error++; - $errmsg=$acct->error; - $errmsgs=$acct->errors; - setEventMessages($errmsg, $errmsgs, 'errors'); - } - } - else - { - $error++; - $errmsg=$acct->error; - $errmsgs=$acct->errors; - setEventMessages($errmsg, $errmsgs, 'errors'); - } - } - - // If option choosed, we create invoice - if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly') - { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; - - $invoice=new Facture($db); - $customer=new Societe($db); - - if (! $error) - { - if (! ($object->fk_soc > 0)) - { - $langs->load("errors"); - $errmsg=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); - setEventMessages($errmsg, null, 'errors'); - $error++; - } - } - if (! $error) - { - $result=$customer->fetch($object->fk_soc); - if ($result <= 0) - { - $errmsg=$customer->error; - $errmsgs=$acct->errors; - setEventMessages($errmsg, $errmsgs, 'errors'); - $error++; - } - } - - if (! $error) - { - // Create draft invoice - $invoice->type= Facture::TYPE_STANDARD; - $invoice->cond_reglement_id=$customer->cond_reglement_id; - if (empty($invoice->cond_reglement_id)) - { - $paymenttermstatic=new PaymentTerm($db); - $invoice->cond_reglement_id=$paymenttermstatic->getDefaultId(); - if (empty($invoice->cond_reglement_id)) - { - $error++; - $errmsg='ErrorNoPaymentTermRECEPFound'; - setEventMessages($errmsg, null, 'errors'); - } - } - $invoice->socid=$object->fk_soc; - $invoice->date=$datesubscription; - - // Possibility to add external linked objects with hooks - $invoice->linked_objects['subscription'] = $crowid; - if (! empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects'])) - { - $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']); - } - - $result=$invoice->create($user); - if ($result <= 0) - { - $errmsg=$invoice->error; - $errmsgs=$invoice->errors; - setEventMessages($errmsg, $errmsgs, 'errors'); - $error++; - } - } - - if (! $error) - { - // Add line to draft invoice - $idprodsubscription=0; - if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS; - - $vattouse=0; - if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') - { - $vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription); - } - //print xx".$vattouse." - ".$mysoc." - ".$customer;exit; - $result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datesubscription,$datesubend,0,0,'','TTC',$subscription,1); - if ($result <= 0) - { - $errmsg=$invoice->error; - setEventMessages($errmsg, null, 'errors'); - $error++; - } - } - - if (! $error) - { - // Validate invoice - $result=$invoice->validate($user); - if ($result <= 0) - { - $errmsg=$invoice->error; - $errmsgs=$invoice->errors; - setEventMessages($errmsg, $errmsgs, 'errors'); - $error++; - } - } - - // Add payment onto invoice - if ($option == 'bankviainvoice' && $accountid) - { - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; - - $amounts[$invoice->id] = price2num($subscription); - $paiement = new Paiement($db); - $paiement->datepaye = $paymentdate; - $paiement->amounts = $amounts; - $paiement->paiementid = dol_getIdFromCode($db,$operation,'c_paiement','code','id',1); - $paiement->num_paiement = $num_chq; - $paiement->note = $label; - - if (! $error) - { - // Create payment line for invoice - $paiement_id = $paiement->create($user); - if (! $paiement_id > 0) - { - $errmsg=$paiement->error; - $errmsgs=$paiement->errors; - setEventMessages($errmsg, $errmsgs, 'errors'); - $error++; - } - } - - if (! $error) - { - // Add transaction into bank account - $bank_line_id=$paiement->addPaymentToBank($user,'payment','(SubscriptionPayment)',$accountid,$emetteur_nom,$emetteur_banque); - if (! ($bank_line_id > 0)) - { - $errmsg=$paiement->error; - $errmsgs=$paiement->errors; - setEventMessages($paiement->error, $paiement->errors, 'errors'); - $error++; - } - } - - if (! $error) - { - // Update fk_bank into subscription table - $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id; - $sql.= ' WHERE rowid='.$crowid; - - $result = $db->query($sql); - if (! $result) - { - $error++; - } - } - - if (! $error) - { - // 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); - } - } - } + $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } if (! $error) @@ -557,7 +338,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if (! $error) { // Send confirmation Email - if ($object->email && $_POST["sendmail"]) + if ($object->email && $sendalsoemail) { $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); $texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); @@ -569,7 +350,11 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! setEventMessages($errmsg, null, 'errors'); } } + } + // Clean some POST vars + if (! $error) + { $_POST["subscription"]=''; $_POST["accountid"]=''; $_POST["operation"]=''; @@ -933,7 +718,7 @@ if ($rowid > 0) print load_fiche_titre($langs->trans("NewCotisation")); - // Define default choice to select + // Define default choice for complementary actions $bankdirect=0; // 1 means option by default is write to bank direct with no invoice $invoiceonly=0; // 1 means option by default is invoice only $bankviainvoice=0; // 1 means option by default is write to bank via invoice @@ -944,11 +729,11 @@ if ($rowid > 0) if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice=1; } else - { + { if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $bankviainvoice=1; - else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && ! empty($conf->banque->enabled)) $bankdirect=1; + else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && ! empty($conf->banque->enabled)) $bankdirect=1; else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $invoiceonly=1; - } + } print "\n\n\n"; @@ -1047,15 +832,11 @@ if ($rowid > 0) } if (! $datefrom) { - if ($object->datefin > 0) + $datefrom=$object->datevalid; + if ($object->datefin > 0) { $datefrom=dol_time_plus_duree($object->datefin,1,'d'); } - else - { - //$datefrom=dol_now(); - $datefrom=$object->datevalid; - } } print $form->select_date($datefrom,'','','','',"subscription",1,1,1); print ""; @@ -1207,7 +988,7 @@ if ($rowid > 0) $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); $texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); - $tmp='global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked':'')).'>'; + $tmp='global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked':'')).'>'; $helpcontent=''; $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; $helpcontent.=''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index dc995a4f88b..4c1b49d75e6 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -48,9 +48,11 @@ $MAXAGENDA=$conf->global->AGENDA_EXT_NB; // List of aviable colors $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); + /* * Actions */ + if ($actionsave) { $db->begin(); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index b2b7efc3a1c..1a0680363a9 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -313,10 +313,9 @@ if ($action == 'edit' || $action == 'updateedit') print '
'; print ''; print ''; - $var=true; print ''; - print ''."\n"; + print ''."\n"; // Name @@ -411,7 +410,6 @@ if ($action == 'edit' || $action == 'updateedit') // IDs of the company (country-specific) print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'; print ''; - $var=true; $langs->load("companies"); @@ -697,11 +695,12 @@ else //print ''.$langs->trans("Modify").''; //print '
'; + print '
'; print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; print ''; - print ''; @@ -791,7 +790,7 @@ else print ''; print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").''; + print '
'.$langs->trans("CompanyName").''; if (! empty($conf->global->MAIN_INFO_SOCIETE_NOM)) print $conf->global->MAIN_INFO_SOCIETE_NOM; else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyName")).''; print '
'.$langs->trans("Note").'' . (! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) : '') . '
'; - + print ""; print '
'; @@ -799,8 +798,10 @@ else // IDs of the company (country-specific) print ''; print ''; + + print '
'; print ''; - print ''; + print ''; // Managing Director(s) @@ -956,12 +957,16 @@ else print ''; print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("CompanyObject").'' . (! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? nl2br($conf->global->MAIN_INFO_SOCIETE_OBJECT) : '') . '
'; + print "
"; + print '
'; /* * fiscal year beginning */ print '
'; + + print '
'; print ''; print ''; print ''; @@ -973,11 +978,13 @@ else print dol_print_date(dol_mktime(12,0,0,$monthstart,1,2000,1),'%B','gm') . ''; print "
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
"; + print "
"; /* * tax options */ print '
'; + print '
'; print ''; print ''; print ''; @@ -1005,7 +1012,7 @@ else print "\n"; print "
'.$langs->trans("VATManagement").''.$langs->trans("Description").'
"; - + print "
"; /* * Local Taxes @@ -1014,6 +1021,7 @@ else { // Local Tax 1 print '
'; + print '
'; print ''; print ''; print ''; @@ -1061,11 +1069,13 @@ else print "\n"; print "
'.$langs->transcountry("LocalTax1Management",$mysoc->country_code).''.$langs->trans("Description").'
"; + print "
"; } if ($mysoc->useLocalTax(2)) // True if we found at least on vat with a setup adding a localtax 1 { // Local Tax 2 print '
'; + print '
'; print ''; print ''; print ''; @@ -1113,6 +1123,7 @@ else print "\n"; print "
'.$langs->transcountry("LocalTax2Management",$mysoc->country_code).''.$langs->trans("Description").'
"; + print "
"; } diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 8028c81cf04..2f1ae179948 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -611,18 +611,6 @@ else // Show print ''.$langs->trans("Value").''."\n"; print "\n"; - if (! empty($dolibarr_pdf_force_fpdf)) - { - - print ''."\n"; - print 'dolibarr_pdf_force_fpdf'."\n"; - print ''; - print $dolibarr_pdf_force_fpdf; - print ''; - print ''; - } - - print ''."\n"; print ''.$langs->trans("LibraryToBuildPDF").''."\n"; print ''; @@ -663,11 +651,6 @@ else // Show print "\n"; print ''; - if (! empty($dolibarr_pdf_force_fpdf)) - { - print info_admin($langs->trans("WarningUsingFPDF")).'
'; - } - print '
'; print ''.$langs->trans("Modify").''; print '
'; diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index 19fa3fc1abd..d6e05ed2e72 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -75,7 +75,7 @@ else } } - if ($base == 1) + if ($base == 1) // mysql { $link=array(); $cons = explode(";", $row[14]); @@ -97,11 +97,19 @@ else // var_dump($link); - print ''; - print ''; - print ''; + print '
'.$langs->trans("Fields").''.$langs->trans("Type").''.$langs->trans("Index").''.$langs->trans("FieldsLinked").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $sql = "DESCRIBE ".$table; + //$sql = "DESCRIBE ".$table; + $sql = "SHOW FULL COLUMNS IN ".$db->escape($table); + $resql = $db->query($sql); if ($resql) { @@ -111,12 +119,18 @@ else { $row = $db->fetch_row($resql); print ''; - print ""; - print ""; - print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; - + + print ''; print ''; $i++; } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index c36db521f70..468a2c493a7 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -116,7 +116,7 @@ if (function_exists('curl_init')) } else { - print $langs->trans("LastStableVersion").' : ' .$langs->trans("Check").''; + print $langs->trans("LastStableVersion").' : ' .$langs->trans("Check").''; } } @@ -325,13 +325,14 @@ $configfileparameters=array( '?dolibarr_font_DOL_DEFAULT_TTF_BOLD' => 'dolibarr_font_DOL_DEFAULT_TTF_BOLD', 'separator4' => '', 'dolibarr_main_prod' => 'Production mode (Hide all error messages)', + 'dolibarr_main_restrict_os_commands' => 'Restrict CLI commands for backups', + 'dolibarr_main_restrict_ip' => 'Restrict access to some IPs only', '?dolibarr_mailing_limit_sendbyweb' => 'Limit nb of email sent by page', '?dolibarr_mailing_limit_sendbycli' => 'Limit nb of email sent by cli', - '?dolibarr_strict_mode' => 'Strict mode is on/off', - '?dolibarr_pdf_force_fpdf' => 'Force fpdf usage to generate PDF' + '?dolibarr_strict_mode' => 'Strict mode is on/off', + '?dolibarr_nocsrfcheck' => 'Disable CSRF security checks' ); -$var=true; print '
'; print '
'.$langs->trans("Fields").''.$langs->trans("Type").''.$langs->trans("Index").''.$langs->trans("FieldsLinked").'
$row[0]$row[1]$row[3]".$row[0]."".$row[1]."".$row[3]."".(empty($row[4])?'':$row[4])."".(empty($row[5])?'':$row[5])."".(empty($row[6])?'':$row[6])."".(empty($row[7])?'':$row[7])."".(isset($link[$row[0]][0])?$link[$row[0]][0]:'')."."; print (isset($link[$row[0]][1])?$link[$row[0]][1]:'')."
'; print ''; @@ -441,8 +442,8 @@ if ($resql) $obj = $db->fetch_object($resql); print ''; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; if (empty($conf->multicompany->enabled) || !$user->entity) print ''."\n"; // If superadmin or multicompany disabled print "\n"; diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index f904c7750f8..5899f1877fa 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -32,6 +32,7 @@ if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core $langs->load('admin'); $langs->load('objects'); $langs->load("companies"); +$langs->load("products"); if (!$user->admin) accessforbidden(); diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index d508d1edceb..9410ef9be5e 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -474,7 +474,7 @@ if (is_array($blocks)) print ''; // Link to source object - print ''; + print ''; // Amount print ''; @@ -501,7 +501,7 @@ if (is_array($blocks)) print ''; - // Status note + // Note print ''; $s.='global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").''; + print ''; // Full day event print ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index ed0950826b8..6452e3ca922 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -212,7 +212,7 @@ class ActionComm extends CommonObject $now=dol_now(); // Check parameters - if (empty($this->userownerid)) + if (! isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 { dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); $this->errors[]='ErrorPropertyUserowneridNotDefined'; @@ -1236,8 +1236,12 @@ class ActionComm extends CommonObject $result=''; - // Set label of typ - $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label; + // Set label of type + $labeltype = ''; + if ($this->type_code) + { + $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label; + } if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); @@ -1289,7 +1293,7 @@ class ActionComm extends CommonObject $linkstart.=$linkclose.'>'; $linkend=''; - //print 'rrr'.$this->libelle.'-'.$withpicto; + //print 'rrr'.$this->libelle.'rrr'.$this->label.'rrr'.$withpicto; if ($withpicto == 2) { @@ -1309,7 +1313,10 @@ class ActionComm extends CommonObject { if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () { - $libelle.=(($this->type_code && $libelle!=$langs->transnoentities("Action".$this->type_code) && $langs->transnoentities("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->transnoentities("Action".$this->type_code).')':''); + if ($labeltype) + { + $libelle.=(preg_match('/'.preg_quote($labeltype,'/').'/', $libelle)?'':' ('.$langs->transnoentities("Action".$this->type_code).')'); + } } } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index efdad6a3738..9fae2dd47a9 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -589,6 +589,7 @@ if ($resql) $event->type_color=$obj->type_color; $event->libelle=$obj->label; + $event->label=$obj->label; $event->percentage=$obj->percent; $event->authorid=$obj->fk_user_author; // user id of creator $event->userownerid=$obj->fk_user_action; // user id of owner @@ -601,7 +602,9 @@ if ($resql) $event->elementtype=$obj->elementtype; $event->societe->id=$obj->fk_soc; + $event->thirdparty_id=$obj->fk_soc; $event->contact->id=$obj->fk_contact; + $event->contact_id=$obj->fk_contact; // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. @@ -1176,19 +1179,72 @@ else // View by day $timestamp=dol_mktime(12,0,0,$month,$day,$year); $arraytimestamp=dol_getdate($timestamp); - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - echo '
'.$obj->name.''.$obj->value.''.$obj->name.''.dol_escape_htmltag($obj->value).''.$obj->entity.'
'.$block->ref_object.''.$object_link.''.$object_link.''.price($block->amounts).''; if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error { diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index c8a9cbf70be..a092b13ca99 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -87,7 +87,7 @@ function formatObject($objtoshow, $prefix) { $s.='
'.($prefix?$prefix.' > ':'').$key.''; - if (in_array($key, array('date','datef'))) + if (in_array($key, array('date','datef','dateh','datec','datem','datep'))) { $s.=dol_print_date($val, 'dayhour'); } diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 3dc3ade52e5..1bddb23de1d 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -239,6 +239,17 @@ class BlockedLog $this->error++; } } + else if($this->element === 'subscription') { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + + $object = new Subscription($this->db); + if ($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + else{ + $this->error++; + } + } else if ($this->action == 'MODULE_SET') { return 'System to track events into unalterable logs were enabled'; @@ -313,6 +324,10 @@ class BlockedLog { $this->date_object = $object->datepaid?$object->datepaid:$object->datep; } + elseif ($object->element=='subscription') + { + $this->date_object = $object->dateh; + } else { $this->date_object = $object->date; } @@ -323,7 +338,10 @@ class BlockedLog // id of object $this->fk_object = $object->id; + + // Set object_data $this->object_data=new stdClass(); + $arrayoffieldstoexclude = array('table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','modelpdf','table_element_line','linkedObjectsIds','linkedObjects','fk_delivery_address'); // Add thirdparty info if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty(); @@ -333,7 +351,7 @@ class BlockedLog foreach($object->thirdparty as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' @@ -349,7 +367,7 @@ class BlockedLog foreach($mysoc as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' @@ -366,12 +384,11 @@ class BlockedLog } // Field specific to object - if ($this->element == 'facture') { foreach($object as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public','lines' ))) continue; // Discard if not into a dedicated list @@ -402,7 +419,7 @@ class BlockedLog { foreach($object as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' ))) continue; // Discard if not into a dedicated list @@ -498,7 +515,7 @@ class BlockedLog $paymentpart->thirdparty = new stdClass(); foreach($tmpobject->thirdparty as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' @@ -515,7 +532,7 @@ class BlockedLog { foreach($tmpobject as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' ))) continue; // Discard if not into a dedicated list @@ -542,6 +559,29 @@ class BlockedLog if (! empty($object->newref)) $this->object_data->ref = $object->newref; } + elseif($this->element == 'subscription') + { + foreach($object as $key=>$value) + { + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (! in_array($key, array( + 'id','datec','dateh','datef','fk_adherent','amount','import_key','statut','note' + ))) continue; // Discard if not into a dedicated list + if (!is_object($value)) $this->object_data->{$key} = $value; + } + + if (! empty($object->newref)) $this->object_data->ref = $object->newref; + } + else // Generic case + { + foreach($object as $key=>$value) + { + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!is_object($value)) $this->object_data->{$key} = $value; + } + + if (! empty($object->newref)) $this->object_data->ref = $object->newref; + } return 1; } @@ -667,11 +707,12 @@ class BlockedLog return -2; } - if (empty($this->action) || empty($this->fk_user) || empty($this->user_fullname)) { + if (empty($this->action)) { $this->error=$langs->trans("BadParameterWhenCallingCreateOfBlockedLog"); dol_syslog($this->error, LOG_WARNING); return -3; } + if (empty($this->fk_user)) $this->user_fullname='(Anonymous)'; $this->date_creation = dol_now(); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 2f59df43803..d0d97f83435 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1044,7 +1044,7 @@ if ($id > 0) } // Title - print '
'.$langs->trans("Title").'
'.$langs->trans("EventOnFullDay").'fulldayevent?' checked':'').'>
'; - echo ' '; - echo ' \n"; - echo " \n"; - echo " \n"; - echo ' \n"; - echo " \n"; + //echo '
'.$langs->trans("Day".$arraytimestamp['wday'])."
'; - $maxnbofchar=80; - show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); - echo "
'; + echo '
'; + + echo ' '; + echo ' '; + echo ' \n"; + echo " \n"; + + /* + echo '
'; + echo '
'; + echo '
'; + echo show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, -1); + echo '
'."\n"; + echo "
\n"; + */ + echo '
'.$langs->trans("Day".$arraytimestamp['wday'])."
'; - print ''; + + /* WIP View per hour */ + $useviewhour = 0; + if ($useviewhour) + { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + + $maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500)?($_SESSION["dol_screenheight"]-200):660; // Also into index.php file + + echo '
'; + echo '
'; + + $maxnbofchar=80; + + $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); + $minhour = round($tmp[0],0); + $maxhour = round($tmp[1],0); + if ($minhour > 23) $minhour = 23; + if ($maxhour < 1) $maxhour = 1; + if ($maxhour <= $minhour) { $maxhour = $minhour + 1; } + + $i = 0; + $j = 0; + while ($i < 24) + { + echo '
'."\n"; + echo '
'.dol_print_date($i*3600, 'hour', 'gmt').'
'; + echo '
'; + echo "
\n"; + echo "
\n"; + $i++; + $j++; + } + + echo '
'; + + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1); + + print '
'; + } + else + { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); + + print '
'; + } } print "\n".''; @@ -1213,9 +1269,10 @@ $db->close(); * @param string $newparam Parameters on current URL * @param int $showinfo Add extended information (used by day and week view) * @param int $minheight Minimum height for each event. 60px by default. + * @param string $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button" * @return void */ -function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60) +function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60, $nonew=0) { global $user, $conf, $langs; global $action, $filter, $filtert, $status, $actioncode; // Filters used into search form @@ -1230,26 +1287,35 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $curtime = dol_mktime(0, 0, 0, $month, $day, $year); print '
'."\n"; - print '
'; - if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) + if ($nonew <= 0) { - $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; + print '
'; + if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) + { + $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; - //$param='month='.$monthshown.'&year='.$year; - $hourminsec='100000'; - print ''; - print img_picto($langs->trans("NewAction"),'edit_add.png'); - print ''; + //$param='month='.$monthshown.'&year='.$year; + $hourminsec='100000'; + print ''; + print img_picto($langs->trans("NewAction"),'edit_add.png'); + print ''; + } + print '
'."\n"; + } + + if ($nonew < 0) + { + print '
'; + return; } - print '
'."\n"; // Line with td contains all div of each events print '
'; @@ -1390,6 +1456,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa //print ' position: absolute; top: 40px; width: 50%;'; //print '"'; print '>'; + //var_dump($event->userassigned); //var_dump($event->transparency); print ''; if (! empty($arrayfields['a.label']['checked'])) print ''; if (! empty($arrayfields['a.datep']['checked'])) { - print ''; } if (! empty($arrayfields['a.datep2']['checked'])) { - print ''; } @@ -517,8 +517,8 @@ if ($resql) print ''; + // Ref if (! empty($arrayfields['a.id']['checked'])) { - // Ref print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d514bbaf603..7c49ff909d6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -239,7 +239,7 @@ class Facture extends CommonInvoice * @param int $forceduedate 1=Do not recalculate due date from payment condition but force it with value * @return int <0 if KO, >0 if OK */ - function create($user,$notrigger=0,$forceduedate=0) + function create(User $user, $notrigger=0, $forceduedate=0) { global $langs,$conf,$mysoc,$hookmanager; $error=0; @@ -265,13 +265,13 @@ class Facture extends CommonInvoice $this->multicurrency_tx = 1; } - dol_syslog(get_class($this)."::create user=".$user->id); + dol_syslog(get_class($this)."::create user=".$user->id." date=".$this->date); // Check parameters - if (empty($this->date) || empty($user->id)) + if (empty($this->date)) { - $this->error="ErrorBadParameter"; - dol_syslog(get_class($this)."::create Try to create an invoice with an empty parameter (user, date, ...)", LOG_ERR); + $this->error="Try to create an invoice with an empty parameter (date)"; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -3; } $soc = new Societe($this->db); @@ -2242,7 +2242,7 @@ class Facture extends CommonInvoice // Validate $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; + $sql.= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date { $sql.= ", datef='".$this->db->idate($this->date)."'"; @@ -2365,9 +2365,12 @@ class Facture extends CommonInvoice $final = ($this->lines[$i]->situation_percent == 100); $i++; } - if ($final) { - $this->setFinal($user); - } + + if (empty($final)) $this->situation_final = 0; + else $this->situation_final = 1; + + $this->setFinal($user); + } } } @@ -4070,7 +4073,6 @@ class Facture extends CommonInvoice $this->db->begin(); - $this->situation_final = 1; $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $this->situation_final . ' where rowid = ' . $this->id; dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index e1b5af4e88d..8d955f1141d 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1189,7 +1189,7 @@ if ($action == 'create') $disableedit=1; $disablemove=1; $disableremove=1; - $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } print "
'; + print ''; print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1); print ''; + print ''; print $form->select_date($dateend, 'dateend', 0, 0, 1, '', 1, 0, 1); print '
'; print $actionstatic->getNomUrl(1,-1); print '
\n"; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index bacaddcffd4..625336a0fe4 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -701,19 +701,19 @@ if ($resql) // Date invoice if (! empty($arrayfields['f.date']['checked'])) { - print ''; + print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($year?$year:-1,'year',1, 20, 5); + $formother->select_year($year?$year:-1,'year',1, 20, 5, 0, 0, '', 'width75'); print ''; } // Date due if (! empty($arrayfields['f.date_lim_reglement']['checked'])) { - print ''; + print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); + $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5, 0, 0, '', 'width75'); print '
'.$langs->trans("Late"); print ''; } diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 570942590c2..79a88d11c4d 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -132,7 +132,7 @@ class Localtax extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user=null, $notrigger=0) + function update(User $user, $notrigger=0) { global $conf, $langs; @@ -149,8 +149,8 @@ class Localtax extends CommonObject $this->db->begin(); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."localtax SET"; - $sql.= " localtaxtype=".$this->ltt.","; + $sql = "UPDATE ".MAIN_DB_PREFIX."localtax SET"; + $sql.= " localtaxtype=".$this->ltt.","; $sql.= " tms='".$this->db->idate($this->tms)."',"; $sql.= " datep='".$this->db->idate($this->datep)."',"; $sql.= " datev='".$this->db->idate($this->datev)."',"; @@ -160,7 +160,7 @@ class Localtax extends CommonObject $sql.= " fk_bank=".$this->fk_bank.","; $sql.= " fk_user_creat=".$this->fk_user_creat.","; $sql.= " fk_user_modif=".$this->fk_user_modif; - $sql.= " WHERE rowid=".$this->id; + $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -255,12 +255,12 @@ class Localtax extends CommonObject } - /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK - */ + /** + * Delete object in database + * + * @param User $user User that delete + * @return int <0 if KO, >0 if OK + */ function delete($user) { // Call trigger @@ -285,11 +285,11 @@ class Localtax extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ function initAsSpecimen() { diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 11751fe258b..4f17a4444f5 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -88,11 +88,11 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); $paiement_id = 0; $totalpayment = 0; $multicurrency_totalpayment = 0; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 42106c1cb13..4d23637dfe7 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -209,9 +209,10 @@ class Paiement extends CommonObject $total = $totalamount_converted; // Maybe use price2num with MT for the converted value $mtotal = $totalamount; } + $note = ($this->note_public?$this->note_public:$this->note); $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_creat)"; - $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.")"; + $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($note)."', ".$user->id.")"; dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/paiement/avalider.php b/htdocs/compta/paiement/tovalidate.php similarity index 96% rename from htdocs/compta/paiement/avalider.php rename to htdocs/compta/paiement/tovalidate.php index beb2fb77ecd..7e16b525233 100644 --- a/htdocs/compta/paiement/avalider.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -17,9 +17,9 @@ */ /** - * \file htdocs/compta/paiement/avalider.php + * \file htdocs/compta/paiement/tovalidate.php * \ingroup compta - * \brief Page liste des paiements a valider des factures clients + * \brief Page list payment to validate. Visible in menu when option BILL_ADD_PAYMENT_VALIDATION is on. */ require '../../main.inc.php'; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index c829b139436..64811c7604a 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -205,7 +205,7 @@ if ($result) print_liste_field_titre("Bill",$_SERVER["PHP_SELF"],"p.ref",'',$param,'',$sortfield,$sortorder); print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom",'',$param,'',$sortfield,$sortorder); print_liste_field_titre("AmountInvoice",$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre("AmountRequested",$_SERVER["PHP_SELF"],"pl.amount_requested","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre("AmountRequested",$_SERVER["PHP_SELF"],"pl.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("StatusDebitCredit",$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index fe7d927b6df..1bbeb9f2f29 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -255,7 +255,7 @@ if ($modecompta == 'BOOKKEEPING') $sql.= " WHERE f.numero_compte = aa.account_number"; //$sql.= " AND fk_statut in (1,2)"; $sql.= " AND ".$predefinedgroupwhere; - $sql.= " AND aa.fk_pcg_version = '".$charofaccountstring."'"; + $sql.= " AND f.entity = ".$conf->entity; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY pcg_type, pcg_subtype, name, socid"; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 156576fa4bc..26f12e3f7c5 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -828,7 +828,6 @@ if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING')) if (! empty($date_start) && ! empty($date_end)) $sql.= " AND b.doc_date >= '".$db->idate($date_start)."' AND b.doc_date <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, dm"; - //print $sql; dol_syslog("get bookkeeping record"); diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 335cf581740..598de2ba490 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -142,9 +142,7 @@ else if ($modecompta=="BOOKKEEPING") $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $periodlink=($year_start?"".img_previous()." ".img_next()."":""); - $description=$langs->trans("RulesCADue"); - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); - else $description.= $langs->trans("DepositsAreIncluded"); + $description=$langs->trans("RulesCATotalSaleJournal"); $builddate=dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } @@ -187,15 +185,14 @@ if ($socid) $sql.= " AND f.fk_soc = ".$socid; else if ($modecompta=="BOOKKEEPING") { $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql.= " WHERE b.numero_compte IN (SELECT a.account_number" ; - $sql.= " FROM ".MAIN_DB_PREFIX."accounting_account as a"; - $sql.= " WHERE a.fk_accounting_category = 1 ) " ; // todo sql with accounting category, but we need to define category in turnover + $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj"; + $sql.= " WHERE b.entity = ".$conf->entity; + $sql.= " AND b.code_journal = aj.code AND aj.nature = 2" ; // @TODO currently count amount in sale journal, but we need to define a category group for turnover } - $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm"; +//print $sql; $result = $db->query($sql); if ($result) @@ -221,7 +218,7 @@ else { } // On ajoute les paiements anciennes version, non lies par paiement_facture (very old versions) -if ($modecompta != 'CREANCES-DETTES') +if ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -269,10 +266,11 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++) { if ($modecompta == 'CREANCES-DETTES') print ''; else print ''; - print ''; + if ($modecompta != 'BOOKKEEPING') print ''; print $annee; if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) print '-'.($annee+1); - print ''; + if ($modecompta != 'BOOKKEEPING') print ''; + print ''; if ($annee != $year_end) print ' '; } print ''; @@ -336,7 +334,9 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) if ($cum[$case]) { $now_show_delta=1; // On a trouve le premier mois de la premiere annee generant du chiffre. - print ''.price($cum[$case],1).''; + if ($modecompta != 'BOOKKEEPING') print ''; + print price($cum[$case], 1); + if ($modecompta != 'BOOKKEEPING') print ''; } else { diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 7f938ba9b6c..6e5ac327e9b 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -176,11 +176,11 @@ elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('l } elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha')) { - // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. - if (! empty($upload_dir)) - { - $filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'), '_', 0); // Do not remove accents - $filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'), '_', 0); // Do not remove accents + // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. + if (! empty($upload_dir)) + { + $filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'), '_', 0); // Do not remove accents + $filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'), '_', 0); // Do not remove accents if ($filenamefrom != $filenameto) { @@ -197,23 +197,38 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha')) $srcpath = $upload_dir.'/'.$filenamefrom; $destpath = $upload_dir.'/'.$filenameto; - $result = dol_move($srcpath, $destpath); - if ($result) + $reshook=$hookmanager->initHooks(array('actionlinkedfiles')); + $parameters=array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir); + $reshook=$hookmanager->executeHooks('renameUploadedFile', $parameters, $object); + + if (empty($reshook)) { - if ($object->id) + if (! file_exists($destpath)) { - $object->addThumbs($destpath); + $result = dol_move($srcpath, $destpath); + if ($result) + { + if ($object->id) + { + $object->addThumbs($destpath); + } + + // TODO Add revert function of addThumbs to remove for old name + //$object->delThumbs($srcpath); + + setEventMessages($langs->trans("FileRenamed"), null); + } + else + { + $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); + } + } + else + { + $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorDestinationAlreadyExists", $filenameto), null, 'errors'); } - - // TODO Add revert function of addThumbs to remove for old name - //$object->delThumbs($srcpath); - - setEventMessages($langs->trans("FileRenamed"), null); - } - else - { - $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. - setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); } } } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 9e1e89d60fc..9bbde140dbe 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -136,7 +136,7 @@ class box_commandes extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100"', + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $societestatic->getNomUrl(1), 'asis' => 1, ); diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 59db96b08aa..49d6df67d7f 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -128,7 +128,7 @@ class box_contracts extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $thirdpartytmp->getNomUrl(1), 'asis'=>1 ); diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 4c95d446f8a..d665d70da56 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -91,6 +91,8 @@ class box_graph_invoices_permonth extends ModeleBoxes if ($user->rights->facture->lire) { + $mesg = ''; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 3261572460e..53449afceeb 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -131,13 +131,13 @@ class box_produits extends ModeleBoxes $productstatic->entity = $objp->entity; $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $productstatic->getNomUrl(1), 'asis' => 1, ); $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $objp->label, ); diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 9dc75612773..ee49e9e4534 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -144,7 +144,7 @@ class box_produits_alerte_stock extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $objp->label, ); diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index a94ee0c1f08..8dad41f64a1 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -131,13 +131,13 @@ class box_propales extends ModeleBoxes ); $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100"', + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $societestatic->getNomUrl(1), 'asis' => 1, ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', + 'td' => 'class="right nowraponall"', 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), ); diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 0cc4e68682b..44a1ca020b5 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -177,7 +177,7 @@ class box_services_contracts extends ModeleBoxes } - $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $s, 'asis' => 1 ); @@ -187,7 +187,7 @@ class box_services_contracts extends ModeleBoxes 'asis' => 1 ); - $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $thirdpartytmp->getNomUrl(1), 'asis' => 1 ); diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index f123872b85b..72d4390a2e2 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -126,7 +126,7 @@ class box_services_expired extends ModeleBoxes 'asis' => 1 ); - $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone" align="left"', + $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax150 maxwidth150onsmartphone" align="left"', 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), 'asis' => 1 ); diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 025cfba71a5..74f0ffc9d9d 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -248,7 +248,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" $out.= '>'; if ($conf->use_javascript_ajax) { - $out.= ''; } else diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index ccc1f9b77bd..35077eb5bc5 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -74,7 +74,9 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping',21); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_VALIDATE','Member validated','Executed when a member is validated','member',22); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SENTBYMAIL','Mails sent from member card','Executed when you send email from member card','member',23); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION','Member subscribed','Executed when a member is subscribed','member',24); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION_CREATE','Member subscribtion recorded','Executed when a member subscribtion is deleted','member',24); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION_MODIFY','Member subscribtion modified','Executed when a member subscribtion is modified','member',24); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION_DELETE','Member subscribtion deleted','Executed when a member subscribtion is deleted','member',24); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_RESILIATE','Member resiliated','Executed when a member is resiliated','member',25); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_DELETE','Member deleted','Executed when a member is deleted','member',26); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_VALIDATE','Intervention validated','Executed when a intervention is validated','ficheinter',30); diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index e3e78d4a338..442b99fbfb1 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -94,6 +94,11 @@ ALTER TABLE llx_website_page ADD COLUMN type_container varchar(16) NOT NULL DEFA -- For 7.0 +delete from llx_c_action_trigger where code = 'MEMBER_SUBSCRIPTION'; +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION_CREATE','Member subscribtion recorded','Executed when a member subscribtion is deleted','member',24); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION_MODIFY','Member subscribtion modified','Executed when a member subscribtion is modified','member',24); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION_DELETE','Member subscribtion deleted','Executed when a member subscribtion is deleted','member',24); + ALTER TABLE llx_product_attribute_value DROP INDEX unique_ref; ALTER TABLE llx_product_attribute_value ADD UNIQUE INDEX uk_product_attribute_value (fk_product_attribute, ref); @@ -437,7 +442,7 @@ CREATE TABLE llx_expensereport_rules ( fk_usergroup integer DEFAULT NULL, fk_c_type_fees integer NOT NULL, code_expense_rules_type varchar(50) NOT NULL, - is_for_all tinyint DEFAULT '0', + is_for_all tinyint DEFAULT 0, entity integer DEFAULT 1 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_expensereport_rules.sql b/htdocs/install/mysql/tables/llx_expensereport_rules.sql index 3aaca6f00b5..feacf572c1f 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_rules.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_rules.sql @@ -29,6 +29,6 @@ CREATE TABLE llx_expensereport_rules ( fk_usergroup integer DEFAULT NULL, fk_c_type_fees integer NOT NULL, code_expense_rules_type varchar(50) NOT NULL, - is_for_all tinyint DEFAULT '0', + is_for_all tinyint DEFAULT 0, entity integer DEFAULT 1 ) ENGINE=InnoDB; \ No newline at end of file diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0c5962c1183..d6514db4d2c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -420,7 +420,6 @@ ExtrafieldParamHelpsellist=List of values comes from a table
Syntax : table_n ExtrafieldParamHelpchkbxlst=List of values comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another complementary attribute list :
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter ExtrafieldParamHelplink=Parameters must be ObjectName:Classpath
Syntax : ObjectName:Classpath
Examples :
Societe:societe/class/societe.class.php
Contact:contact/class/contact.class.php LibraryToBuildPDF=Library used for PDF generation -WarningUsingFPDF=Warning: Your conf.php contains directive dolibarr_pdf_force_fpdf=1. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.
To solve this and have a full support of PDF generation, please download TCPDF library, then comment or remove the line $dolibarr_pdf_force_fpdf=1, and add instead $dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir' LocalTaxDesc=Some countries apply 2 or 3 taxes on each invoice line. If this is the case, choose type for second and third tax and its rate. Possible type are:
1 : local tax apply on products and services without vat (localtax is calculated on amount without tax)
2 : local tax apply on products and services including vat (localtax is calculated on amount + main tax)
3 : local tax apply on products without vat (localtax is calculated on amount without tax)
4 : local tax apply on products including vat (localtax is calculated on amount + main vat)
5 : local tax apply on services without vat (localtax is calculated on amount without tax)
6 : local tax apply on services including vat (localtax is calculated on amount + tax) SMS=SMS LinkToTestClickToDial=Enter a phone number to call to show a link to test the ClickToDial url for user %s diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 0c70a160204..4ab64a98224 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -53,7 +53,9 @@ MemberValidatedInDolibarr=Member %s validated MemberModifiedInDolibarr=Member %s modified MemberResiliatedInDolibarr=Member %s terminated MemberDeletedInDolibarr=Member %s deleted -MemberSubscriptionAddedInDolibarr=Subscription for member %s added +MemberSubscriptionAddedInDolibarr=Subscription %s for member %s added +MemberSubscriptionModifiedInDolibarr=Subscription %s for member %s modified +MemberSubscriptionDeletedInDolibarr=Subscription %s for member %s deleted ShipmentValidatedInDolibarr=Shipment %s validated ShipmentClassifyClosedInDolibarr=Shipment %s classified billed ShipmentUnClassifyCloseddInDolibarr=Shipment %s classified reopened diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 632ef67feb9..d1413fb0454 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -157,6 +157,7 @@ RulesResultDue=- It includes outstanding invoices, expenses, VAT, donations whet RulesResultInOut=- It includes the real payments made on invoices, expenses, VAT and salaries.
- It is based on the payment dates of the invoices, expenses, VAT and salaries. The donation date for donation. RulesCADue=- It includes the client's due invoices whether they are paid or not.
- It is based on the validation date of these invoices.
RulesCAIn=- It includes all the effective payments of invoices received from clients.
- It is based on the payment date of these invoices
+RulesCATotalSaleJournal=It includes all credit lines from the Sale journal. RulesAmountOnInOutBookkeepingRecord=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" RulesResultBookkeepingPredefined=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting accounts grouped by personalized groups diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 41891a9e091..d2c057b6983 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -430,6 +430,9 @@ ActionsOnCompany=Events about this third party ActionsOnMember=Events about this member ActionsOnProduct=Events about this product NActionsLate=%s late +ToDo=To do +Completed=Completed +Running=In progress RequestAlreadyDone=Request already recorded Filter=Filter FilterOnInto=Search criteria '%s' into fields %s @@ -707,6 +710,8 @@ WarningYouAreInMaintenanceMode=Warning, you are in a maintenance mode, so only l CoreErrorTitle=System error CoreErrorMessage=Sorry, an error occurred. Contact your system administrator to check the logs or disable $dolibarr_main_prod=1 to get more information. CreditCard=Credit card +ValidatePayment=Validate payment +CreditOrDebitCard=Credit or debit card FieldsWithAreMandatory=Fields with %s are mandatory FieldsWithIsForPublic=Fields with %s are shown on public list of members. If you don't want this, check off the "public" box. AccordingToGeoIPDatabase=(according to GeoIP convertion) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index d90bfb35032..066f761bb32 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -80,8 +80,8 @@ LinkedObject=Linked object NbOfActiveNotifications=Number of notifications (nb of recipient emails) PredefinedMailTest=__(Hello)__\nThis is a test mail sent to __EMAIL__.\nThe two lines are separated by a carriage return.\n\n__USER_SIGNATURE__ PredefinedMailTestHtml=__(Hello)__\nThis is a test mail (the word test must be in bold).
The two lines are separated by a carriage return.

__USER_SIGNATURE__ -PredefinedMailContentSendInvoice=__(Hello)__\n\nYou will find here the invoice __REF__\n\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ -PredefinedMailContentSendInvoiceReminder=__(Hello)__\n\nWe would like to warn you that the invoice __REF__ seems to not be payed. So this is the invoice in attachment again, as a reminder.\n\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendInvoice=__(Hello)__\n\nYou will find here the invoice __REF__\n\nThis is the link to make your online payment if this invoice is not already payed:\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendInvoiceReminder=__(Hello)__\n\nWe would like to warn you that the invoice __REF__ seems to not be payed. So this is the invoice in attachment again, as a reminder.\n\nThis is the link to make your online payment:\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendProposal=__(Hello)__\n\nYou will find here the commercial proposal __PREF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendSupplierProposal=__(Hello)__\n\nYou will find here the price request __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendOrder=__(Hello)__\n\nYou will find here the order __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index e1db55d5668..25f06dacd42 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -30,4 +30,6 @@ ErrorCode=Error Code ErrorSeverityCode=Error Severity Code OnlinePaymentSystem=Online payment system PaypalLiveEnabled=Paypal live enabled (otherwise test/sandbox mode) -PaypalImportPayment=Import Paypal payments \ No newline at end of file +PaypalImportPayment=Import Paypal payments +PostActionAfterPayment=Post actions after payments +ARollbackWasPerformedOnPostActions=A rollback was performed on all Post actions. You must complete post actions manually if they are necessary. \ No newline at end of file diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index ff6b4a58608..2b5823c28fb 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -38,4 +38,5 @@ STRIPE_TEST_PUBLISHABLE_KEY=Publishable test key STRIPE_LIVE_SECRET_KEY=Secret live key STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key StripeLiveEnabled=Stripe live enabled (otherwise test/sandbox mode) -StripeImportPayment=Import Stripe payments \ No newline at end of file +StripeImportPayment=Import Stripe payments +ExampleOfTestCreditCard=Example of credit card for test: %s (valid), %s (error CVC), %s (expired), %s (charge fails) \ No newline at end of file diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index 85d1f6a5b58..ff24ea0c023 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -224,8 +224,8 @@ GeneralLedgerSomeRecordWasNotRecorded=Certaines des opérations n'ont pu être e NoNewRecordSaved=Plus d'enregistrements à journaliser ListOfProductsWithoutAccountingAccount=Liste des produits non liés à un compte comptable ChangeBinding=Changer les liens -Accounted=Comptabilisé dans le grand livre -NotYetAccounted=Pas encore comptabilisé dans le grand livre +Accounted=Comptabilisé +NotYetAccounted=Pas encore comptabilisé ## Admin ApplyMassCategories=Application en masse des catégories diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 610a4f59ab3..d34ca3c3498 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -78,8 +78,8 @@ LinkedObject=Objet lié NbOfActiveNotifications=Nombre de notifications (nb de destinataires emails) PredefinedMailTest=__(Hello)__,\nCeci est un mail de test envoyé à __EMAIL__.\nLes deux lignes sont séparées par un saut de ligne.\n\n__USER_SIGNATURE__ PredefinedMailTestHtml=__(Hello)__\nCeci est un message de test (le mot test doit être en gras).
Les 2 lignes sont séparées par un retour à la ligne.

__SIGNATURE__ -PredefinedMailContentSendInvoice=__(Hello)__\n\nVeuillez trouver, ci-joint, la facture __REF__\n\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ -PredefinedMailContentSendInvoiceReminder=__(Hello)__\n\nNous voulons porter à votre connaissance le fait que la facture __REF__ semble non payée. Aussi, voici la facture à nouveau en pièce jointe pour rappel.\n\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendInvoice=__(Hello)__\n\nVeuillez trouver, ci-joint, la facture __REF__\n\nVoici le lien pour un paiement en ligne au cas ou celle-ci n'aurait pas encore été payé:\n\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendInvoiceReminder=__(Hello)__\n\nNous voulons porter à votre connaissance le fait que la facture __REF__ semble non payée. Aussi, voici la facture à nouveau en pièce jointe pour rappel.\n\nVoici le lien pour un paiement en ligne:\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendProposal=__(Hello)__\n\nVeuillez trouver, ci-joint, la proposition commerciale __PREF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendSupplierProposal=__(Hello)__\n\nVeuillez trouver, ci-joint, une demande de prix avec la référence __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendOrder=__(Hello)__\n\nVeuillez trouver, ci-joint, la commande __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index 79a6a62ad2a..1db6c1906a3 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -55,6 +55,8 @@ if ($action == 'setvalue' && $user->admin) $result=dolibarr_set_const($db, "PAYBOX_PBX_IDENTIFIANT",GETPOST('PAYBOX_PBX_IDENTIFIANT','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR",GETPOST('ONLINE_PAYMENT_CREDITOR','alpha'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS",GETPOST('PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS','int'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL",GETPOST('ONLINE_PAYMENT_CSS_URL','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; @@ -183,6 +185,15 @@ print '
'.$langs->trans("Example").': '.$mysoc->name; print ''; +if (! empty($conf->banque->enabled)) +{ + print ''; +} + + print ''; +if (! empty($conf->banque->enabled)) +{ + print ''; +} print ''; } + if (! empty($arrayfields['m.price']['checked'])) + { + // Price + print ''; + } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook @@ -849,8 +859,11 @@ if ($resql) if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder); + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook @@ -976,6 +989,13 @@ if ($resql) print $objp->qty; print ''; } + if (! empty($arrayfields['m.price']['checked'])) + { + // Price + print ''; + } // Action column print ''; if ($object->element == 'product') { - print ''; - print ''; + print ''; - print ''; + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; // Purchase price print ''; - print ''; + print ''; print ''; if (! empty($conf->projet->enabled)) { print ''; print ''; } print ''; @@ -133,7 +133,7 @@ if (empty($conf) || ! is_object($conf)) print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 18f6b831cf2..4c89b97622f 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -72,20 +72,20 @@ if (empty($conf) || ! is_object($conf)) print ''; if ($object->element == 'product') { - print ''; - print ''; + print ''; } if ($object->element == 'stock') { - print ''; - print ''; + print ''; } - print ''; print ''; @@ -125,11 +125,11 @@ if (empty($conf) || ! is_object($conf)) // Label $valformovementlabel=(GETPOST("label")?GETPOST("label"):$langs->trans("MovementTransferStock", $productref)); print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print '
'; + $out.= ''; $boxstat.='
'; } if (! empty($head['text'])) { diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index f5a16aa540b..a4ea3a70447 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -319,7 +319,7 @@ abstract class CommonDocGenerator foreach($conf->global as $key => $val) { - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****'; else $newval = $val; $array_other['__['.$key.']__'] = $newval; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c7335298bdd..7e565e0222f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2739,7 +2739,7 @@ abstract class CommonObject * @param string $targettype Object target type (if not defined, elemennt name of object) * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided * @param int $alsosametype 0=Return only links to object that differs from source. 1=Include also link to objects of same type. - * @return void + * @return int <0 if KO, >0 if OK * @see add_object_linked, updateObjectLinked, deleteObjectLinked */ function fetchObjectLinked($sourceid=null,$sourcetype='',$targetid=null,$targettype='',$clause='OR',$alsosametype=1) @@ -2920,10 +2920,12 @@ abstract class CommonObject } } } + return 1; } else { dol_print_error($this->db); + return -1; } } @@ -3582,7 +3584,7 @@ abstract class CommonObject * Return HTML table for object lines * TODO Move this into an output class file (htmlline.class.php) * If lines are into a template, title must also be into a template - * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. + * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * * @param string $action Action code * @param string $seller Object of seller third party @@ -4518,6 +4520,7 @@ abstract class CommonObject } else { + global $extrafields; dol_syslog("Warning: fetch_optionals was called with param optionsArray defined when you should pass null now", LOG_WARNING); } @@ -4691,7 +4694,8 @@ abstract class CommonObject if ($this->array_options[$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) { // If there is an encryption choice, we use it to crypt data before insert - $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); + $tmparrays = array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options']); + $algo=reset($tmparrays); if ($algo != '') { //global $action; // $action may be 'create', 'update', 'update_extras'... diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4477a4812da..861848e6924 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -235,6 +235,7 @@ class ExtraFields $lengthdb='11'; } elseif ($type=='html') { $typedb='text'; + $lengthdb=$length; } elseif($type=='password') { $typedb='varchar'; $lengthdb='128'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index df26e44e080..7b74fc05850 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3421,7 +3421,8 @@ class Form } else { - print $langs->trans("NoActiveBankAccountDefined"); + if ($statut == 0) print $langs->trans("NoActiveBankAccountDefined"); + else print $langs->trans("NoBankAccountFound"); } } else { diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 2d66661c839..f254fe44b9d 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -194,6 +194,7 @@ class FormActions $projectid = $object->fk_project; if ($typeelement == 'project') $projectid = $object->id; + $buttontoaddnewevent=''; if (! empty($conf->agenda->enabled)) { $buttontoaddnewevent = ''; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index d3990acc9c8..faa548a5d16 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -545,9 +545,10 @@ class FormCompany * @param array $limitto Disable answers that are not id in this array list * @param int $forceid This is to force another object id than object->id * @param string $moreparam String with more param to add into url when noajax search is used. + * @param string $morecss More CSS on select component * @return int The selected third party ID */ - function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='') + function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='', $morecss='') { global $conf, $langs; @@ -649,7 +650,7 @@ class FormCompany $resql = $this->db->query($sql); if ($resql) { - print ''; - if ($useempty == 1 || ($useempty == 2 && $num > 1)) + + if ($useempty == 1 || $useempty == 2) { $out .= ''; } @@ -196,7 +196,6 @@ class FormWebsite } $out .= $langs->trans($val); $out .= ''; - $i++; } $out .= ""; diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 7d5f742a779..37ccea748f1 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -67,7 +67,7 @@ class Utils // Delete temporary files if ($dolibarr_main_data_root) { - $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', '', '', 2, 0, '', 1); // Do not follow symlinks + $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', 'name', SORT_ASC, 2, 0, '', 1); // Do not follow symlinks if ($choice == 'tempfilesold') { $now = dol_now(); @@ -81,10 +81,10 @@ class Utils if ($choice=='allfiles') { - // Delete all files (except install.lock) + // Delete all files (except install.lock, do not follow symbolic links) if ($dolibarr_main_data_root) { - $filesarray=dol_dir_list($dolibarr_main_data_root,"all",0,'','install\.lock$'); + $filesarray=dol_dir_list($dolibarr_main_data_root, "all", 0, '', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1); } } @@ -93,7 +93,7 @@ class Utils // Define files log if ($dolibarr_main_data_root) { - $filesarray=dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*$', 'install\.lock$'); + $filesarray=dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*$', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1); } $filelog=''; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index fcc3098c730..0f219a032cc 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1288,9 +1288,10 @@ function complete_elementList_with_modules(&$elementList) $modules[$i] = $objMod; $filename[$i]= $modName; - $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module + $orders[$i] = $objMod->family."_".$j; // Sort on family then module number + $dirmod[$i] = $dir; //print "x".$modName." ".$orders[$i]."\n
"; - $dirmod[$i] = $dirroot; + if (! empty($objMod->module_parts['contactelement'])) { $elementList[$objMod->name] = $langs->trans($objMod->name); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4a9d4e6bc5e..fd10db135c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1077,11 +1077,12 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title + * @param string $morecss More Css * @return void */ -function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='') +function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='') { - print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright); + print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss); } /** @@ -1094,9 +1095,10 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto * @param string $picto Add a picto on tab title * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title + * @param string $morecss More Css * @return string */ -function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='') +function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='') { global $conf, $langs, $hookmanager; @@ -1161,7 +1163,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi { if (!empty($links[$i][0])) { - $out.='
'.$links[$i][1].''."\n"; + $out.=''.$links[$i][1].''."\n"; } else { @@ -1173,13 +1175,13 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi //print "x $i $active ".$links[$i][2]." z"; if ($isactive) { - $out.=''; + $out.=''; $out.=$links[$i][1]; $out.=''."\n"; } else { - $out.=''; + $out.=''; $out.=$links[$i][1]; $out.=''."\n"; } @@ -1198,14 +1200,14 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi if (isset($links[$i][2]) && $links[$i][2] == 'image') { if (!empty($links[$i][0])) - $outmore.=''.$links[$i][1].''."\n"; + $outmore.=''.$links[$i][1].''."\n"; else $outmore.=''.$links[$i][1].''."\n"; } else if (! empty($links[$i][1])) { - $outmore.=''; + $outmore.=''; $outmore.=preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. $outmore.=''."\n"; } @@ -1489,6 +1491,14 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($object->frequency == 0) $morehtmlstatus.=$object->getLibStatut(2); else $morehtmlstatus.=$object->getLibStatut(5); } + elseif ($object->element == 'project_task') + { + $object->fk_statut = 1; + if ($object->progress > 0) $object->fk_statut = 2; + if ($object->progress >= 100) $object->fk_statut = 3; + $tmptxt=$object->getLibStatut(5); + $morehtmlstatus.=$tmptxt; // No status on task + } else { // Generic case $tmptxt=$object->getLibStatut(6); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5); diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 82e9a98d43f..50716c27aca 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -177,6 +177,7 @@ function redirectToContainer($containerref, $containeraliasalt='',$containerid=0 global $db, $website; $newurl = ''; + $result=0; // We make redirect using the alternative alias, we must find the real $containerref if ($containeraliasalt) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 1237b72f826..000c228ef8e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -818,7 +818,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { - $newmenu->add("/compta/paiement/avalider.php?leftmenu=customers_bills_tovalid",$langs->trans("MenuToValid"),2,$user->rights->facture->lire,'',$mainmenu,'customer_bills_tovalid'); + $newmenu->add("/compta/paiement/tovalidate.php?leftmenu=customers_bills_tovalid",$langs->trans("MenuToValid"),2,$user->rights->facture->lire,'',$mainmenu,'customer_bills_tovalid'); } $newmenu->add("/compta/paiement/rapport.php?leftmenu=customers_bills_reports",$langs->trans("Reportings"),2,$user->rights->facture->lire,'',$mainmenu,'customers_bills_reports'); diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index c700f4d6984..71b744fa67b 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -91,7 +91,7 @@ if ($permission) { '; ?>
trans("Users"); ?>
global->MAIN_INFO_SOCIETE_NOM; ?>
-
select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56); ?>
+
select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?>
- selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0); ?> + selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, '', 'minwidth300imp'); ?>
- select_contacts($selectedCompany, '', 'contactid', 0, '', '', 0, 'minwidth200'); ?> + select_contacts($selectedCompany, '', 'contactid', 0, '', '', 0, 'minwidth100imp'); ?>
element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc; - $formcompany->selectTypeContact($tmpobject, '', 'type','external'); ?> + $formcompany->selectTypeContact($tmpobject, '', 'type','external', 'position', 0, 'minwidth100imp'); ?>
 
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 3c34d0a3ee0..78053a0631c 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -655,20 +655,53 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid=0; } - elseif ($action == 'MEMBER_SUBSCRIPTION') + elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE') { $langs->load("agenda"); $langs->load("other"); $langs->load("members"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->getFullName($langs)); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->getFullName($langs)); + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs)); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day'); $object->sendtoid=0; + if ($object->fk_soc > 0) $object->socid=$object->fk_soc; + } + elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY') + { + $langs->load("agenda"); + $langs->load("other"); + $langs->load("members"); + + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs)); + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day'); + + $object->sendtoid=0; + if ($object->fk_soc > 0) $object->socid=$object->fk_soc; + } + elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE') + { + $langs->load("agenda"); + $langs->load("other"); + $langs->load("members"); + + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs)); + $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; + $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; + $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day'); + + $object->sendtoid=0; + if ($object->fk_soc > 0) $object->socid=$object->fk_soc; } elseif ($action == 'MEMBER_RESILIATE') { @@ -816,6 +849,14 @@ class InterfaceActionsAuto extends DolibarrTriggers $projectid = isset($object->fk_project)?$object->fk_project:0; if ($object->element == 'project') $projectid = $object->id; + $elementid = $object->id; + $elementtype = $object->element; + if ($object->element == 'subscription') + { + $elementid = $object->fk_adherent; + $elementtype = 'member'; + } + // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); @@ -845,8 +886,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->email_subject = $object->email_subject; $actioncomm->errors_to = $object->errors_to; - $actioncomm->fk_element = $object->id; - $actioncomm->elementtype = $object->element; + $actioncomm->fk_element = $elementid; + $actioncomm->elementtype = $elementtype; $ret=$actioncomm->create($user); // User creating action diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index ec0b0cb6941..f97d1400018 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -69,14 +69,16 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $amounts = 0; if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL' || $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL' - || $action==='MEMBER_SUBCRIPTION_CREATE' || $action==='MEMBER_SUBCRIPTION_MODIFY' || $action==='MEMBER_SUBCRIPTION_DELETE' + || $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE' || $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE' || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW') ) { $qualified++; - if ($action==='DON_VALIDATE') $amounts = (double) $object->amount; + if (in_array($action, array( + 'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE', + 'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount; else $amounts = (double) $object->total_ttc; } /*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED' diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b8eef6b5102..61b95c50064 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -398,7 +398,7 @@ class Expedition extends CommonObject if (($lineId = $expeditionline->insert()) < 0) { - $this->error[]=$expeditionline->error; + $this->errors[]=$expeditionline->error; } return $lineId; } @@ -2383,9 +2383,9 @@ class ExpeditionLigne extends CommonObjectLine $error=0; // Check parameters - if (empty($this->fk_expedition) || empty($this->fk_origin_line) || empty($this->qty)) + if (empty($this->fk_expedition) || empty($this->fk_origin_line) || ! is_numeric($this->qty)) { - $this->errors[] = 'ErrorMandatoryParametersNotProvided'; + $this->error = 'ErrorMandatoryParametersNotProvided'; return -1; } // Clean parameters @@ -2425,7 +2425,6 @@ class ExpeditionLigne extends CommonObjectLine $result=$this->call_trigger('LINESHIPPING_INSERT',$user); if ($result < 0) { - $this->errors[]=$this->error; $error++; } // End call triggers @@ -2441,6 +2440,7 @@ class ExpeditionLigne extends CommonObjectLine dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error.=($this->error?', '.$errmsg:$errmsg); } + $this->db->rollback(); return -1*$error; } diff --git a/htdocs/index.php b/htdocs/index.php index 3eb1aa2285a..29e716d31ad 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -339,14 +339,14 @@ if (empty($user->societe_id)) } } - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; + $boxstat.='
'; $boxstat.='
'; @@ -583,12 +583,12 @@ if (! empty($valid_dashboardlines)) $boxwork .="\n"; } - $boxwork .='
'; - $boxwork .='
'; - $boxwork .='
'; - $boxwork .='
'; - $boxwork .='
'; - $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; + $boxwork .='
'; $boxwork .='
'; + print $langs->trans("BankAccount").''; + print $form->select_comptes($conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + print '
'; print $langs->trans("CSSUrlForPaymentForm").''; print ''; diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index 711f898901c..23bf26d375f 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -55,6 +55,8 @@ if ($action == 'setvalue' && $user->admin) if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR",GETPOST('ONLINE_PAYMENT_CREDITOR','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS",GETPOST('PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS','int'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; $result=dolibarr_set_const($db, "PAYPAL_API_INTEGRAL_OR_PAYPALONLY",GETPOST('PAYPAL_API_INTEGRAL_OR_PAYPALONLY','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL",GETPOST('ONLINE_PAYMENT_CSS_URL','alpha'),'chaine',0,'',$conf->entity); @@ -210,6 +212,13 @@ print 'name; print '
'; + print $langs->trans("BankAccount").''; + print $form->select_comptes($conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS, 'PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + print '
'; print $langs->trans("CSSUrlForPaymentForm").''; diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index ecdd2f4fc3e..c34e964c522 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -192,7 +192,7 @@ function getPaypalPaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f * @param string $returnURL Url to use if payment is OK * @param string $cancelURL Url to use if payment is KO * @param string $tag Full tag - * @return void + * @return string No return (a redirect is done) if OK, or Error message if KO */ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$returnURL,$cancelURL,$tag) { @@ -272,11 +272,20 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); - echo $langs->trans('SetExpressCheckoutAPICallFailed') . "
\n"; - echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; - echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
\n"; - echo $langs->trans('ErrorCode') . ": " . $ErrorCode."
\n"; - echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
\n"; + if ($ErrorCode == 10729) + { + $mesg.= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; + } + else + { + $mesg = $langs->trans('SetExpressCheckoutAPICallFailed') . "
\n"; + $mesg.= $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."
\n"; + $mesg.= $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."
\n"; + $mesg.= $langs->trans('ErrorCode') . ": " . $ErrorCode."
\n"; + $mesg.= $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."
\n"; + } + + return $mesg; } } @@ -300,6 +309,7 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re * phoneNum: the phoneNum entered on the merchant's site * email: the buyer email * desc: Product description + * See https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/ * * @param double $paymentAmount Payment amount * @param string $currencyCodeType Currency @@ -307,8 +317,8 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re * @param string $returnURL Return Url * @param string $cancelURL Cancel Url * @param string $tag Full tag - * @param string $solutionType Type - * @param string $landingPage Landing page + * @param string $solutionType Type ('Mark' or 'Sole') + * @param string $landingPage Landing page ('Login' or 'Billing') * @param string $shipToName Ship to name * @param string $shipToStreet Ship to street * @param string $shipToCity Ship to city @@ -327,38 +337,86 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation //declaring of global variables - global $conf, $langs; + global $conf, $langs, $mysoc; global $API_Endpoint, $API_Url, $API_version, $USE_PROXY, $PROXY_HOST, $PROXY_PORT; global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; $nvpstr = ''; - $nvpstr = $nvpstr . "&AMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT - $nvpstr = $nvpstr . "&PAYMENTACTION=" . urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION + //$nvpstr = $nvpstr . "&VERSION=".$API_version; // Already added by hash_call $nvpstr = $nvpstr . "&RETURNURL=" . urlencode($returnURL); $nvpstr = $nvpstr . "&CANCELURL=" . urlencode($cancelURL); - $nvpstr = $nvpstr . "&CURRENCYCODE=" . urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE - $nvpstr = $nvpstr . "&ADDROVERRIDE=1"; - //$nvpstr = $nvpstr . "&ALLOWNOTE=0"; - $nvpstr = $nvpstr . "&SHIPTONAME=" . urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME - $nvpstr = $nvpstr . "&SHIPTOSTREET=" . urlencode($shipToStreet); // - $nvpstr = $nvpstr . "&SHIPTOSTREET2=" . urlencode($shipToStreet2); - $nvpstr = $nvpstr . "&SHIPTOCITY=" . urlencode($shipToCity); - $nvpstr = $nvpstr . "&SHIPTOSTATE=" . urlencode($shipToState); - $nvpstr = $nvpstr . "&SHIPTOCOUNTRYCODE=" . urlencode($shipToCountryCode); - $nvpstr = $nvpstr . "&SHIPTOZIP=" . urlencode($shipToZip); - $nvpstr = $nvpstr . "&PHONENUM=" . urlencode($phoneNum); + if (! empty($conf->global->PAYPAL_ALLOW_NOTES)) + { + $nvpstr = $nvpstr . "&ALLOWNOTE=0"; + } + if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS)) + { + $nvpstr = $nvpstr . "&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted + } + else + { + $nvpstr = $nvpstr . "&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) + } $nvpstr = $nvpstr . "&SOLUTIONTYPE=" . urlencode($solutionType); $nvpstr = $nvpstr . "&LANDINGPAGE=" . urlencode($landingPage); - //$nvpstr = $nvpstr . "&CUSTOMERSERVICENUMBER=" . urlencode($tag); // Hotline phone number - $nvpstr = $nvpstr . "&INVNUM=" . urlencode($tag); - if (! empty($email)) $nvpstr = $nvpstr . "&EMAIL=" . urlencode($email); - if (! empty($desc)) $nvpstr = $nvpstr . "&DESC=" . urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC + if (! empty($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER)) + { + $nvpstr = $nvpstr . "&CUSTOMERSERVICENUMBER=" . urlencode($conf->global->PAYPAL_CUSTOMER_SERVICE_NUMBER); // Hotline phone number + } + $paypalprefix = 'PAYMENTREQUEST_0_'; + //$paypalprefix = ''; + if (! empty($paypalprefix) && $paymentType == 'Sole') $paymentType='Sale'; + + $nvpstr = $nvpstr . "&AMT=". urlencode($paymentAmount); // Total for all elements + + $nvpstr = $nvpstr . "&".$paypalprefix."INVNUM=" . urlencode($tag); + $nvpstr = $nvpstr . "&".$paypalprefix."AMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr . "&".$paypalprefix."ITEMAMT=". urlencode($paymentAmount); // AMT deprecated by paypal -> PAYMENTREQUEST_n_AMT + $nvpstr = $nvpstr . "&".$paypalprefix."PAYMENTACTION=" . urlencode($paymentType); // PAYMENTACTION deprecated by paypal -> PAYMENTREQUEST_n_PAYMENTACTION + $nvpstr = $nvpstr . "&".$paypalprefix."CURRENCYCODE=" . urlencode($currencyCodeType); // CURRENCYCODE deprecated by paypal -> PAYMENTREQUEST_n_CURRENCYCODE + + $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_QTY0=1"; + $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_AMT0=".urlencode($paymentAmount); + $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NAME0=".urlencode($desc); + $nvpstr = $nvpstr . "&".$paypalprefix."L_PAYMENTREQUEST_0_NUMBER0=0"; + + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTONAME=" . urlencode($shipToName); // SHIPTONAME deprecated by paypal -> PAYMENTREQUEST_n_SHIPTONAME + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET=" . urlencode($shipToStreet); // + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTREET2=" . urlencode($shipToStreet2); + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCITY=" . urlencode($shipToCity); + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOSTATE=" . urlencode($shipToState); + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCOUNTRYCODE=" . urlencode($shipToCountryCode); + $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOZIP=" . urlencode($shipToZip); + $nvpstr = $nvpstr . "&".$paypalprefix."PHONENUM=" . urlencode($phoneNum); + if (! empty($email)) $nvpstr = $nvpstr . "&".$paypalprefix."EMAIL=" . urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL + if (! empty($desc)) $nvpstr = $nvpstr . "&".$paypalprefix."DESC=" . urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC + + if (! empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) + { + global $dolibarr_main_url_root; + + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $urllogo=$urlwithroot."/viewimage.php?modulepart=mycompany&file=".$mysoc->logo; + $nvpstr = $nvpstr . "&LOGOIMG=" . urlencode($urllogo); + } + if (! empty($conf->global->PAYPAL_BRANDNAME)) + { + $nvpstr = $nvpstr . "&BRANDNAME=" . urlencode($conf->global->PAYPAL_BRANDNAME); // BRANDNAME + } + if (! empty($conf->global->PAYPAL_NOTETOBUYER)) + { + $nvpstr = $nvpstr . "&NOTETOBUYER=" . urlencode($conf->global->PAYPAL_NOTETOBUYER); // PAYPAL_NOTETOBUYER + } $_SESSION["FinalPaymentAmt"] = $paymentAmount; $_SESSION["currencyCodeType"] = $currencyCodeType; - $_SESSION["PaymentType"] = $paymentType; - $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR ']; // Payer ip + $_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole' + $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip //'--------------------------------------------------------------------------------------------------------------- //' Make the API call to PayPal @@ -534,7 +592,7 @@ function hash_call($methodName,$nvpStr) global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; // TODO problem with triggers - $API_version="56"; + $API_version="98.0"; if (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha')) // We can force sand box with param 'forcesandbox' { $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index e7329f1d44a..b41a990fbc1 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -101,8 +101,9 @@ $arrayfields=array( 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), 'm.label'=>array('label'=>$langs->trans("LabelMovement"), 'checked'=>1), 'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1), - 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1), - //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1), + 'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'checked'=>0), + //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); @@ -417,7 +418,7 @@ if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db); $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type, p.entity,"; $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; -$sql.= " m.batch,"; +$sql.= " m.batch, m.price,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields @@ -634,7 +635,7 @@ if ($resql) /* */ /* ************************************************************************** */ - if (empty($action) && $id > 0) + if ((empty($action) || $action == 'list') && $id > 0) { print "
\n"; @@ -810,8 +811,17 @@ if ($resql) print ''; print '
'; + print '  '; + print ''; + print price($objp->price); + print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 732fa8c889d..d946a23bf70 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -68,8 +68,8 @@ if (empty($conf) || ! is_object($conf)) print '
'.$langs->trans("Warehouse").''; + print ''.$langs->trans("Warehouse").''; print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):'ifone')), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); print '   '.$langs->trans("Product").''; - print $form->select_produits(GETPOST('product_id'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 20, 0, -1); + print ''.$langs->trans("Product").''; + print $form->select_produits(GETPOST('product_id'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 20, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); print '   '; print ''.$langs->trans("NumberOfUnit").''.$langs->trans("NumberOfUnit").'
'.$langs->trans("UnitPurchaseValue").''.$langs->trans("UnitPurchaseValue").''.$langs->trans('Project').''; - $formproject->select_projects(); + $formproject->select_projects(0, '', 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth300'); print '
'.$langs->trans("MovementLabel").''; - print ''; + print ''; print ''.$langs->trans("InventoryCode").'
'.$langs->trans("WarehouseSource").''; + print ''.$langs->trans("WarehouseSource").''; print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):'ifone')), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); print ''.$langs->trans("Product").''; - print $form->select_produits(GETPOST('product_id'),'product_id',(empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':'')); + print ''.$langs->trans("Product").''; + print $form->select_produits(GETPOST('product_id'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 20, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); print ''.$langs->trans("WarehouseTarget").''; + print ''.$langs->trans("WarehouseTarget").''; print $formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1); print '
'.$langs->trans("NumberOfUnit").'
'.$langs->trans("MovementLabel").''.$langs->trans("MovementLabel").''; - print ''; + print ''; print ''.$langs->trans("InventoryCode").''.$langs->trans("InventoryCode").'
'; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index eeacf27aaec..28b3c9b12f3 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1696,7 +1696,7 @@ class Task extends CommonObject */ function getLibStatut($mode=0) { - return $this->LibStatut($this->fk_statut,$mode); + return $this->LibStatut($this->fk_statut, $mode); } /** @@ -1706,18 +1706,18 @@ class Task extends CommonObject * @param integer $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function LibStatut($statut,$mode=0) + function LibStatut($statut, $mode=0) { // list of Statut of the task $this->statuts[0]='Draft'; - $this->statuts[1]='Validated'; + $this->statuts[1]='ToDo'; $this->statuts[2]='Running'; $this->statuts[3]='Finish'; $this->statuts[4]='Transfered'; $this->statuts_short[0]='Draft'; - $this->statuts_short[1]='Validated'; + $this->statuts_short[1]='ToDo'; $this->statuts_short[2]='Running'; - $this->statuts_short[3]='Finish'; + $this->statuts_short[3]='Completed'; $this->statuts_short[4]='Transfered'; global $langs; @@ -1735,7 +1735,7 @@ class Task extends CommonObject if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]); if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut1').' '.$langs->trans($this->statuts_short[$statut]); if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut3').' '.$langs->trans($this->statuts_short[$statut]); - if ($statut==3) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]); + if ($statut==3) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]); if ($statut==4) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]); if ($statut==5) return img_picto($langs->trans($this->statuts_short[$statut]),'statut5').' '.$langs->trans($this->statuts_short[$statut]); } @@ -1744,7 +1744,7 @@ class Task extends CommonObject if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut1'); if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut3'); - if ($statut==3) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); + if ($statut==3) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); if ($statut==4) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); if ($statut==5) return img_picto($langs->trans($this->statuts_short[$statut]),'statut5'); } @@ -1753,27 +1753,31 @@ class Task extends CommonObject if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]); if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut3').' '.$langs->trans($this->statuts[$statut]); - if ($statut==3) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); + if ($statut==3) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); if ($statut==4) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); if ($statut==5) return img_picto($langs->trans($this->statuts_short[$statut]),'statut5').' '.$langs->trans($this->statuts[$statut]); } if ($mode == 5) - { - if ($statut==0) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); - if ($statut==1) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut1'); - if ($statut==2) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut3'); - if ($statut==3) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); - if ($statut==4) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); - if ($statut==5) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut5'); - } - if ($mode == 6) { /*if ($statut==0) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); if ($statut==1) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut1'); if ($statut==2) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut3'); - if ($statut==3) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); + if ($statut==3) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); if ($statut==4) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); - if ($statut==5) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut5');*/ + if ($statut==5) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut5'); + */ + //return $this->progress.' %'; + return ' '; + } + if ($mode == 6) + { + /*if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0'); + if ($statut==1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut1'); + if ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut3'); + if ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); + if ($statut==4) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); + if ($statut==5) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut5'); + */ //return $this->progress.' %'; return ' '; } diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index a2bb784c062..a2db82fc0ed 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -285,7 +285,7 @@ if ($id > 0 || ! empty($ref)) //$arrayofuseridoftask=$object->getListContactId('internal'); $head = task_prepare_head($object); - dol_fiche_head($head, 'task_contact', $langs->trans("Task"), -1, 'projecttask'); + dol_fiche_head($head, 'task_contact', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); $param=(GETPOST('withproject')?'&withproject=1':''); diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 7fc0b981902..1cb5acb73b5 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -224,7 +224,7 @@ if ($object->id > 0) } $head = task_prepare_head($object); - dol_fiche_head($head, 'task_document', $langs->trans("Task"), -1, 'projecttask'); + dol_fiche_head($head, 'task_document', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); // Files list constructor $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index da33b8b7607..f915aaf836a 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -202,7 +202,7 @@ if ($object->id > 0) } $head = task_prepare_head($object); - dol_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask'); + dol_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition'); $param=(GETPOST('withproject')?'&withproject=1':''); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index b70c09cb2bd..10f64869257 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -221,7 +221,7 @@ if ($id > 0 || ! empty($ref)) // Tabs for project $tab='tasks'; $head=project_prepare_head($projectstatic); - dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project'), 0, '', ''); $param=($mode=='mine'?'&mode=mine':''); @@ -352,7 +352,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - dol_fiche_head($head, 'task_task', $langs->trans("Task"),0,'projecttask'); + dol_fiche_head($head, 'task_task', $langs->trans("Task"), 0, 'projecttask', 0, '', ''); print ''; @@ -437,7 +437,7 @@ if ($id > 0 || ! empty($ref)) $param=($withproject?'&withproject=1':''); $linkback=$withproject?''.$langs->trans("BackToList").'':''; - dol_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask'); + dol_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); if ($action == 'delete') { diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 174da003e14..5f826baf03e 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -436,7 +436,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (empty($projectidforalltimes)) { $head=task_prepare_head($object); - dol_fiche_head($head, 'task_time', $langs->trans("Task"), -1, 'projecttask'); + dol_fiche_head($head, 'task_time', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); if ($action == 'deleteline') { @@ -547,6 +547,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print ''; + print '
'; print '
'; print ''; @@ -603,7 +604,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print ''; - print '
'; + print ''; + print '
'; + + print ''; print '
'; } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 978c646a524..9c93808e819 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -418,10 +418,12 @@ $extrafields->fetch_name_optionals_label('adherent'); // fetch optionals attr llxHeaderVierge($langs->trans("NewSubscription")); -print load_fiche_titre($langs->trans("NewSubscription")); +print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center'); +print '
'; if (! empty($conf->global->MEMBER_NEWFORM_TEXT)) print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."
\n"; else print $langs->trans("NewSubscriptionDesc",$conf->global->MAIN_INFO_SOCIETE_MAIL)."
\n"; +print '
'; dol_htmloutput_errors($errmsg); diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 74ffcfd120a..37873033535 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -264,6 +264,7 @@ else if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$param * Actions */ +// Action dopayment is called after choosing the payment mode if ($action == 'dopayment') { if ($paymentmethod == 'paypal') @@ -284,10 +285,18 @@ if ($action == 'dopayment') $desc=GETPOST("desc",'alpha'); $mesg=''; - if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); + if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); + $action=''; + } //elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); //elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); - elseif (! $origfulltag) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); + elseif (! $origfulltag) + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); + $action=''; + } //var_dump($_POST); if (empty($mesg)) @@ -310,6 +319,7 @@ if ($action == 'dopayment') dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG); dol_syslog("PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG); dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG); + // All those fields may be empty when making a payment for a free amount for example dol_syslog("shipToName: $shipToName", LOG_DEBUG); dol_syslog("shipToStreet: $shipToStreet", LOG_DEBUG); dol_syslog("shipToCity: $shipToCity", LOG_DEBUG); @@ -327,9 +337,10 @@ if ($action == 'dopayment') //$_SESSION["FinalPaymentAmt"]=$PAYPAL_API_PRICE; // A redirect is added if API call successfull - print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); + $mesg = print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); - exit; + // If we are here, it means the Paypal redirect was not done, so we show error message + $action = ''; } } @@ -379,10 +390,12 @@ if ($action == 'dopayment') // Called when choosing Stripe mode, after the 'dopayment' if ($action == 'charge') { + $amountstripe = $amount; + // Correct the amount according to unit of currency // See https://support.stripe.com/questions/which-zero-decimal-currencies-does-stripe-support $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (! in_array($currency, $arrayzerounitcurrency)) $amount=$amount * 100; + if (! in_array($currency, $arrayzerounitcurrency)) $amountstripe=$amountstripe * 100; dol_syslog("POST keys : ".join(',', array_keys($_POST)), LOG_DEBUG, 0, '_stripe'); dol_syslog("POST values: ".join(',', $_POST), LOG_DEBUG, 0, '_stripe'); @@ -411,7 +424,7 @@ if ($action == 'charge') dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); $charge = \Stripe\Charge::create(array( 'customer' => $customer->id, - 'amount' => price2num($amount, 'MU'), + 'amount' => price2num($amountstripe, 'MU'), 'currency' => $currency, 'description' => 'Stripe payment: '.$FULLTAG, 'metadata' => array("FULLTAG" => $FULLTAG, 'Recipient' => $mysoc->name), @@ -850,7 +863,7 @@ if ($source == 'invoice') print ''."\n"; // Amount - print ''.$langs->trans("Amount"); + print ''.$langs->trans("PaymentAmount"); if (empty($amount) && empty($object->paye)) print ' ('.$langs->trans("ToComplete").')'; print ''; if (empty($object->paye)) @@ -1432,7 +1445,7 @@ if (preg_match('/^dopayment/',$action))
@@ -1442,7 +1455,7 @@ if (preg_match('/^dopayment/',$action))

- + diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index d74305890df..83b672604cc 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -44,13 +44,7 @@ if (! empty($conf->paypal->enabled)) require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; } -$langs->load("main"); -$langs->load("other"); -$langs->load("dict"); -$langs->load("bills"); -$langs->load("companies"); -$langs->load("paybox"); -$langs->load("paypal"); +$langs->loadLangs(array("main","other","dict","bills","companies","paybox","paypal")); // Clean parameters if (! empty($conf->paypal->enabled)) @@ -130,6 +124,8 @@ $object = new stdClass(); // For triggers * View */ +$now = dol_now(); + dol_syslog("Callback url when a payment was done. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"])?dol_escape_htmltag($_SERVER["QUERY_STRING"]):'')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"])?dol_escape_htmltag($_SERVER["SCRIPT_URI"]):''), LOG_DEBUG, 0, '_payment'); $tracepost = ""; @@ -183,7 +179,7 @@ if ($urllogo) if (! empty($conf->paypal->enabled)) { - if ($paymentmethod == 'paypal') + if ($paymentmethod == 'paypal') // We call this page only if payment is ok on payment system { if ($PAYPALTOKEN) { @@ -251,28 +247,308 @@ if (! empty($conf->paypal->enabled)) if (! empty($conf->paybox->enabled)) { - if ($paymentmethod == 'paybox') $ispaymentok = true; // We call this page only if payment is ok + if ($paymentmethod == 'paybox') $ispaymentok = true; // We call this page only if payment is ok on payment system } if (! empty($conf->stripe->enabled)) { - if ($paymentmethod == 'stripe') $ispaymentok = true; // We call this page only if payment is ok + if ($paymentmethod == 'stripe') $ispaymentok = true; // We call this page only if payment is ok on payment system } +// If data not provided from back url, search them into the session env +if (empty($ipaddress)) $ipaddress = $_SESSION['ipaddress']; +if (empty($TRANSACTIONID)) $TRANSACTIONID = $_SESSION['TRANSACTIONID']; +if (empty($FinalPaymentAmt)) $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; +if (empty($paymentType)) $paymentType = $_SESSION["paymentType"]; + +$fulltag = $FULLTAG; +$tmptag=dolExplodeIntoArray($fulltag,'.','='); + + +// Make complementary actions +$ispostactionok = 0; +$postactionmessages = array(); +if ($ispaymentok) +{ + // Set permission for the anonymous user + if (empty($user->rights->societe)) $user->rights->societe=new stdClass(); + if (empty($user->rights->facture)) $user->rights->facture=new stdClass(); + if (empty($user->rights->adherent)) { $user->rights->adherent=new stdClass(); $user->rights->adherent->cotisation=new stdClass(); } + $user->rights->societe->creer = 1; + $user->rights->facture->creer = 1; + $user->rights->adherent->cotisation->creer = 1; + + if (in_array('MEM', array_keys($tmptag))) + { + $defaultdelay=1; + $defaultdelayunit='y'; + + // Record subscription + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + include_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + $adht = new AdherentType($db); + $object = new Adherent($db); + + $result1 = $object->fetch(0, $tmptag['MEM']); + $result2 = $adht->fetch($object->typeid); + + if ($result1 > 0 && $result2 > 0) + { + $paymentTypeId = 0; + if ($paymentmethod == 'paybox') $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS; + if ($paymentmethod == 'paypal') $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS; + if ($paymentmethod == 'stripe') $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; + if (empty($paymentTypeId)) + { + $paymentType = $_SESSION["paymentType"]; + if (empty($paymentType)) $paymentType = 'CB'; + $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); + } + + $currencyCodeType = $_SESSION['currencyCodeType']; + + // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) + if (! empty($FinalPaymentAmt) && $paymentTypeId > 0) + { + // Subscription informations + $datesubscription=$object->datevalid; + if ($object->datefin > 0) + { + $datesubscription=dol_time_plus_duree($object->datefin,1,'d'); + } + $datesubend=dol_time_plus_duree(dol_time_plus_duree($datesubscription,$defaultdelay,$defaultdelayunit),-1,'d'); + $paymentdate=$now; + $amount = $FinalPaymentAmt; + $label='Online subscription '.dol_print_date($now, 'standard').' using '.$paymentmethod.' from '.$ipaddress.' - Transaction ID = '.$TRANSACTIONID; + + // Payment informations + $accountid = 0; + if ($paymentmethod == 'paybox') $accountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; + if ($paymentmethod == 'paypal') $accountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; + if ($paymentmethod == 'stripe') $accountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; + $operation=$paymentType; // Payment mode code + $num_chq=''; + $emetteur_nom=''; + $emetteur_banque=''; + // Define default choice for complementary actions + $option=''; + if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $option='bankviainvoice'; + else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && ! empty($conf->banque->enabled)) $option='bankdirect'; + else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $option='invoiceonly'; + if (empty($option)) $option='none'; + $sendalsoemail = 1; + + // Record the subscription then complementary actions + $db->begin(); + + // Create subscription + $crowid=$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); + if ($crowid <= 0) + { + $error++; + $errmsg=$object->error; + $postactionmessages[] = $errmsg; + $ispostactionok = -1; + } + else + { + $postactionmessages[]='Subscription created'; + $ispostactionok=1; + } + + if (! $error) + { + $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, 1); + if ($result < 0) + { + $error++; + $postactionmessages[] = $object->error; + $postactionmessages = array_merge($postactionmessages, $object->errors); + $ispostactionok = -1; + } + else + { + if ($option == 'bankviainvoice') $postactionmessages[] = 'Invoice, payment and bank record created'; + if ($option == 'bankdirect') $postactionmessages[] = 'Bank record created'; + if ($option == 'invoiceonly') $postactionmessages[] = 'Invoice recorded'; + $ispostactionok = 1; + } + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + + // Send email + if (! $error) + { + // Send confirmation Email + if ($object->email && $sendalsoemail) + { + $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); + if ($result < 0) + { + $errmsg=$object->error; + $postactionmessages[] = $errmsg; + $ispostactionok = -1; + } + } + } + } + else + { + $postactionmessages[] = 'Failed to get a valid value for "amount paid" or "payment type" to record the payment of subscription for member '.$tmptag['MEM']; + $ispostactionok = -1; + } + } + else + { + $postactionmessages[] = 'Member '.$tmptag['MEM'].' for subscription payed was not found'; + $ispostactionok = -1; + } + } + elseif (in_array('INV', array_keys($tmptag))) + { + // Record payment + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $invoice = new Facture($db); + $result = $invoice->fetch(0, $tmptag['INV']); + if ($result) + { + $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; + + $paymentTypeId = 0; + if ($paymentmethod == 'paybox') $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS; + if ($paymentmethod == 'paypal') $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS; + if ($paymentmethod == 'stripe') $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; + if (empty($paymentTypeId)) + { + $paymentType = $_SESSION["paymentType"]; + if (empty($paymentType)) $paymentType = 'CB'; + $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); + } + + $currencyCodeType = $_SESSION['currencyCodeType']; + + // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) + if (! empty($FinalPaymentAmt) && $paymentTypeId > 0) + { + $db->begin(); + + // Creation of payment line + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + $paiement = new Paiement($db); + $paiement->datepaye = $now; + if ($currencyCodeType == $conf->currency) + { + $paiement->amounts = array($invoice->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id + } + else + { + $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt); // Array with all payments dispatching + + $postactionmessages[] = 'Payment was done in a different currency that currency expected of company'; + $ispostactionok = -1; + $error++; // Not yet supported + } + $paiement->paiementid = $paymentTypeId; + $paiement->num_paiement = ''; + $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' using '.$paymentmethod.' from '.$ipaddress.' - Transaction ID = '.$TRANSACTIONID; + + if (! $error) + { + $paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents + if ($paiement_id < 0) + { + $postactionmessages[] = $paiement->error.' '.join("
\n", $paiement->errors); + $ispostactionok = -1; + $error++; + } + else + { + $postactionmessages[] = 'Payment created'; + $ispostactionok=1; + } + } + + if (! $error && ! empty($conf->banque->enabled)) + { + $bankaccountid = 0; + if ($paymentmethod == 'paybox') $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; + if ($paymentmethod == 'paypal') $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; + if ($paymentmethod == 'stripe') $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; + + if ($bankaccountid > 0) + { + $label='(CustomerInvoicePayment)'; + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) $label='(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result=$paiement->addPaymentToBank($user,'payment',$label, $bankaccountid, '', ''); + if ($result < 0) + { + $postactionmessages[] = $paiement->error.' '.joint("
\n", $paiement->errors); + $ispostactionok = -1; + $error++; + } + else + { + $postactionmessages[] = 'Bank entry of payment created'; + $ispostactionok=1; + } + } + else + { + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Not way to record the payment.'; + $ispostactionok = -1; + $error++; + } + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + else + { + $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of invoice '.$tmptag['INV']; + $ispostactionok = -1; + } + } + else + { + $postactionmessages[] = 'Invoice payed '.$tmptag['INV'].' was not found'; + $ispostactionok = -1; + } + } + else + { + // Nothing done + } +} + if ($ispaymentok) { // Get on url call - $fulltag = $FULLTAG; $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; $payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; $currencyCodeType = $_SESSION['currencyCodeType']; $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // From env - $ipaddress = $_SESSION['ipaddress']; - $TRANSACTIONID = $_SESSION['TRANSACTIONID']; // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; @@ -283,7 +559,7 @@ if ($ispaymentok) print $langs->trans("YourPaymentHasBeenRecorded")."
\n"; - print $langs->trans("ThisIsTransactionId",$TRANSACTIONID)."

\n"; + if ($TRANSACTIONID) print $langs->trans("ThisIsTransactionId",$TRANSACTIONID)."

\n"; $key='ONLINE_PAYMENT_MESSAGE_OK'; if (! empty($conf->global->$key)) print $conf->global->$key; @@ -296,6 +572,10 @@ if ($ispaymentok) // Send an email if ($sendemail) { + $companylangs = new Translate('', $conf); + $companylangs->setDefaultLang($mysoc->default_lang); + $companylangs->loadLangs(array('main','members','bills','paypal','paybox')); + $sendto=$sendemail; $from=$conf->global->MAILING_EMAIL_FROM; // Define $urlwithroot @@ -317,25 +597,60 @@ if ($ispaymentok) else $appli.=" ".DOL_VERSION; $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("NewOnlinePaymentReceived"); + $topic='['.$appli.'] '.$companylangs->transnoentitiesnoconv("NewOnlinePaymentReceived"); $content=""; - if (! empty($tmptag['MEM'])) + if (in_array('MEM', array_keys($tmptag))) { - $langs->load("members"); $url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM']; - $content.=$langs->trans("PaymentSubscription")."
\n"; - $content.=$langs->trans("MemberId").': '.$tmptag['MEM']."
\n"; - $content.=$langs->trans("Link").': '.$url.''."
\n"; + $content.=''.$companylangs->trans("PaymentSubscription")."

\n"; + $content.=$companylangs->trans("MemberId").': '.$tmptag['MEM']."
\n"; + $content.=$companylangs->trans("Link").': '.$url.''."
\n"; + } + elseif (in_array('INV', array_keys($tmptag))) + { + $url=$urlwithroot."/compta/facture/card.php?ref=".$tmptag['INV']; + $content.=''.$companylangs->trans("Payment")."

\n"; + $content.=$companylangs->trans("Invoice").': '.$tmptag['INV']."
\n"; + //$content.=$companylangs->trans("ThirdPartyId").': '.$tmptag['CUS']."
\n"; + $content.=$companylangs->trans("Link").': '.$url.''."
\n"; } else { - $content.=$langs->transnoentitiesnoconv("NewOnlinePaymentReceived")."
\n"; + $content.=$companylangs->transnoentitiesnoconv("NewOnlinePaymentReceived")."
\n"; } + $content.=$companylangs->transnoentities("PostActionAfterPayment").' : '; + if ($ispostactionok > 0) + { + //$topic.=' ('.$companylangs->transnoentitiesnoconv("Status").' '.$companylangs->transnoentitiesnoconv("OK").')'; + $content.=''.$companylangs->transnoentitiesnoconv("OK").''; + } + elseif ($ispostactionok == 0) + { + $content.=$companylangs->transnoentitiesnoconv("None"); + } + else + { + $topic.=($ispostactionok ? '' : ' ('.$companylangs->trans("WarningPostActionErrorAfterPayment").')'); + $content.=''.$companylangs->transnoentitiesnoconv("Error").''; + } + $content.='
'."\n"; + foreach($postactionmessages as $postactionmessage) + { + $content.=' * '.$postactionmessage.'
'."\n"; + } + if ($ispostactionok < 0) + { + $content.= $langs->transnoentities("ARollbackWasPerformedOnPostActions"); + } + $content.='
'."\n"; + $content.="
\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; - $content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + $content.=''.$companylangs->transnoentitiesnoconv("TechnicalInformation").":
\n"; + $content.=$companylangs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; + $content.=$companylangs->transnoentitiesnoconv("ThisIsTransactionId").': '.$TRANSACTIONID."
\n"; + $content.=$companylangs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; + $content.="
\n"; + $content.="tag=".$fulltag."
\ntoken=".$onlinetoken."
\npaymentType=".$paymentType."
\ncurrencycodeType=".$currencyCodeType."
\npayerId=".$payerID."
\nipaddress=".$ipaddress."
\nFinalPaymentAmt=".$FinalPaymentAmt."
\n"; $ishtml=dol_textishtml($content); // May contain urls @@ -356,15 +671,12 @@ if ($ispaymentok) else { // Get on url call - $fulltag = $FULLTAG; - $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; + $onlinetoken = empty($PAYPALTOKEN)?$_SESSION['onlinetoken']:$PAYPALTOKEN; $payerID = empty($PAYPALPAYERID)?$_SESSION['payerID']:$PAYPALPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; $currencyCodeType = $_SESSION['currencyCodeType']; $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - // From env - $ipaddress = $_SESSION['ipaddress']; // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; @@ -389,12 +701,14 @@ else if ($paymentmethod == 'paybox' && ! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; if ($paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->STRIPE_PAYONLINE_SENDEMAIL; - $tmptag=dolExplodeIntoArray($fulltag,'.','='); - // Send an email if ($sendemail) { - $sendto=$sendemail; + $companylangs = new Translate('', $conf); + $companylangs->setDefaultLang($mysoc->default_lang); + $companylangs->loadLangs(array('main','members','bills','paypal','paybox')); + + $sendto=$sendemail; $from=$conf->global->MAILING_EMAIL_FROM; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); @@ -415,14 +729,17 @@ else else $appli.=" ".DOL_VERSION; $urlback=$_SERVER["REQUEST_URI"]; - $topic='['.$appli.'] '.$langs->transnoentitiesnoconv("ValidationOfPaymentFailed"); + $topic='['.$appli.'] '.$companylangs->transnoentitiesnoconv("ValidationOfPaymentFailed"); $content=""; - $content.=$langs->transnoentitiesnoconv("PaymentSystemConfirmPaymentPageWasCalledButFailed")."\n"; - $content.="\n"; - $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."\n"; - $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; - $content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; + $content.=''.$companylangs->transnoentitiesnoconv("PaymentSystemConfirmPaymentPageWasCalledButFailed")."\n"; + + $content.="
\n"; + $content.=''.$companylangs->transnoentitiesnoconv("TechnicalInformation").":
\n"; + $content.=$companylangs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."
\n"; + $content.=$companylangs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; + $content.="
\n"; + $content.="tag=".$fulltag."
\ntoken=".$onlinetoken."
\npaymentType=".$paymentType."
\ncurrencycodeType=".$currencyCodeType."
\npayerId=".$payerID."
\nipaddress=".$ipaddress."
\nFinalPaymentAmt=".$FinalPaymentAmt."
\n"; + $ishtml=dol_textishtml($content); // May contain urls @@ -448,6 +765,11 @@ print "\n
\n"; htmlPrintOnlinePaymentFooter($mysoc,$langs,0,$suffix); +// Clean session variables to avoid duplicate actions if post is resent +unset($_SESSION["FinalPaymentAmt"]); +unset($_SESSION["TRANSACTIONID"]); + + llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index b1ecfa43803..24abc52526c 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -250,7 +250,7 @@ if (GETPOST('action','aZ09') == 'dopayment') //$_SESSION["FinalPaymentAmt"]=$PAYPAL_API_PRICE; // A redirect is added if API call successfull - print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); + $mesg = print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); exit; } diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index 36cd64b4f01..ff1b03187c1 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -1168,7 +1168,7 @@ if (preg_match('/^dopayment/',$action))
- + diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 48c35c7143e..94b686c3b35 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1169,7 +1169,7 @@ class Societe extends CommonObject $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; if ($rowid) $sql .= ' AND s.rowid = '.$rowid; if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; - if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($nom_alias)."'"; + if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($ref_alias)."'"; if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; @@ -2833,10 +2833,10 @@ class Societe extends CommonObject //Check NIF if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) - return 1; - else - return -1; + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) + return 1; + else + return -1; //algorithm checking type code CIF $sum = $num[2] + $num[4] + $num[6]; @@ -2846,31 +2846,31 @@ class Societe extends CommonObject //Chek special NIF if (preg_match('/^[KLM]{1}/', $string)) - if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) - return 1; - else - return -1; + if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) + return 1; + else + return -1; //Check CIF if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string)) - if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) - return 2; - else - return -2; + if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) + return 2; + else + return -2; //Check NIE T if (preg_match('/^[T]{1}/', $string)) - if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) - return 3; - else - return -3; + if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) + return 3; + else + return -3; //Check NIE XYZ if (preg_match('/^[XYZ]{1}/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) - return 3; - else - return -3; + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) + return 3; + else + return -3; //Can not be verified return -4; @@ -2894,9 +2894,6 @@ class Societe extends CommonObject else { return -1; } - - //Wrong format - return 0; } return $ok; @@ -3105,6 +3102,8 @@ class Societe extends CommonObject { global $user,$langs; + dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG); + $name = $socname?$socname:$member->societe; if (empty($name)) $name=$member->getFullName($langs); @@ -3137,7 +3136,6 @@ class Societe extends CommonObject $sql.= " SET fk_soc=".$this->id; $sql.= " WHERE rowid=".$member->id; - dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index c658e19fa20..8f7a8ae9d86 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -56,7 +56,9 @@ if ($action == 'setvalue' && $user->admin) $result=dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY",GETPOST('STRIPE_LIVE_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR",GETPOST('ONLINE_PAYMENT_CREDITOR','alpha'),'chaine',0,'',$conf->entity); - if (! $result > 0) $error++; + if (! $result > 0) $error++; + $result=dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_PAYMENTS",GETPOST('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS','int'),'chaine',0,'',$conf->entity); + if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL",GETPOST('ONLINE_PAYMENT_CSS_URL','alpha'),'chaine',0,'',$conf->entity); if (! $result > 0) $error++; $result=dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM",GETPOST('ONLINE_PAYMENT_MESSAGE_FORM','alpha'),'chaine',0,'',$conf->entity); @@ -195,6 +197,14 @@ print 'name; print ''; +if (! empty($conf->banque->enabled)) +{ + print ''; + print $langs->trans("BankAccount").''; + print $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS, 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1); + print ''; +} + print ''; print $langs->trans("CSSUrlForPaymentForm").''; print ''; @@ -253,6 +263,8 @@ $token=''; include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php'; +print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242', '4000000000000101', '4000000000000069', '4000000000000341')); + if (! empty($conf->use_javascript_ajax)) { print "\n".'