Fix : php 8.1 warnings

This commit is contained in:
hystepik 2022-11-27 00:44:05 +01:00
parent fb11f24fae
commit c1b355fcac
8 changed files with 158 additions and 155 deletions

View File

@ -1253,7 +1253,7 @@ if ($action == 'create') {
print $langs->trans("DayOfWeek").': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.'">';
print '</div>';
// limit date
$repeateventlimitdate = $repeateventlimitdate ? $repeateventlimitdate : '';
$repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate : '';
print '<div class="hidden marginrightonly inline-block repeateventlimitdate">';
print $langs->trans("Until")." ";
print $form->selectDate($repeateventlimitdate, 'limit', 0, 0, 0, "action", 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');

View File

@ -1561,6 +1561,7 @@ if ($resql) {
$companylinked_id = 0;
$userlinked_id = 0;
$type_link = "";
//payment line type to define user display and user or company linked
foreach ($links as $key => $value) {

View File

@ -1209,7 +1209,7 @@ class BonPrelevement extends CommonObject
$result = '';
$labeltoshow = 'PaymentByDirectDebit';
if ($this->type == 'bank-transfer') {
if (!empty($this->type) && $this->type == 'bank-transfer') {
$labeltoshow = 'PaymentByBankTransfer';
}
@ -1221,7 +1221,7 @@ class BonPrelevement extends CommonObject
}
$url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id;
if ($this->type == 'bank-transfer') {
if (!empty($this->type) && $this->type == 'bank-transfer') {
$url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id;
}

View File

@ -356,7 +356,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
}
}
}
$texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
$texttoinsert .= ((!empty($val['notnull']) && $val['notnull'] > 0) ? ' NOT NULL' : '');
if ($i < count($object->fields)) {
$texttoinsert .= ", ";
}

View File

@ -332,7 +332,7 @@ if (($id || $ref) && $action == 'edit') {
// $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $sk->$key;
// }
//var_dump($val.' '.$key.' '.$value);
if ($val['noteditable']) {
if (!empty($val['noteditable'])) {
print $sk->showOutputField($val, $key, $value, '', '', '', 0);
} else {
/** @var Skilldet $sk */

View File

@ -3112,7 +3112,7 @@ if ($module == 'initmodule') {
$proplabel = $propval['label'];
$proptype = $propval['type'];
$proparrayofkeyval = !empty($propval['arrayofkeyval'])?$propval['arrayofkeyval']:'';
$propnotnull = $propval['notnull'];
$propnotnull = !empty($propval['notnull']) ? $propval['notnull'] : '0';
$propdefault = !empty($propval['default'])?$propval['default']:'';
$propindex = !empty($propval['index'])?$propval['index']:'';
$propforeignkey = !empty($propval['foreignkey'])?$propval['foreignkey']:'';

View File

@ -1286,7 +1286,7 @@ if ($action == 'create') {
$lines = $object->lines;
$num_prod = count($lines);
$indiceAsked = 0;
if ($object->id > 0) {
if (!empty($object->origin) && $object->origin_id > 0) {
$object->origin = 'CommandeFournisseur';

View File

@ -87,38 +87,18 @@ if (!$rowid) {
$option = array('limit' => $limit + 1);
$num = 0;
$param = '';
$totalnboflines = '';
$moreforfilter = '';
$list = null;
if (GETPOSTISSET('starting_after_'.$page)) {
$option['starting_after'] = GETPOST('starting_after_'.$page, 'alphanohtml');
}
try {
if ($stripeacc) {
$list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc));
} else {
$list = \Stripe\Charge::all($option);
}
$num = count($list->data);
$totalnboflines = '';
$param = '';
//if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
$param .= '&starting_after_'.($page + 1).'='.$list->data[($limit - 1)]->id;
//$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id;
$moreforfilter = '';
} catch (Exception $e) {
print $e->getMessage();
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -145,146 +125,168 @@ if (!$rowid) {
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'right ');
print "</tr>\n";
try {
if ($stripeacc) {
$list = \Stripe\Charge::all($option, array("stripe_account" => $stripeacc));
} else {
$list = \Stripe\Charge::all($option);
}
$num = count($list->data);
//if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
$param .= '&starting_after_'.($page + 1).'='.$list->data[($limit - 1)]->id;
//$param.='&ending_before_'.($page+1).'='.$list->data[($limit-1)]->id;
} catch (Exception $e) {
print '<tr><td colspan="6">'.$e->getMessage().'</td></td>';
}
//print $list;
$i = 0;
foreach ($list->data as $charge) {
if ($i >= $limit) {
break;
}
if (!empty($list)) {
foreach ($list->data as $charge) {
if ($i >= $limit) {
break;
}
if ($charge->refunded == '1') {
$status = img_picto($langs->trans("refunded"), 'statut6');
} elseif ($charge->paid == '1') {
$status = img_picto($langs->trans((string) $charge->status), 'statut4');
} else {
$label = $langs->trans("Message").": ".$charge->failure_message."<br>";
$label .= $langs->trans("Network").": ".$charge->outcome->network_status."<br>";
$label .= $langs->trans("Status").": ".$langs->trans((string) $charge->outcome->seller_message);
$status = $form->textwithpicto(img_picto($langs->trans((string) $charge->status), 'statut8'), $label, -1);
}
if ($charge->refunded == '1') {
$status = img_picto($langs->trans("refunded"), 'statut6');
} elseif ($charge->paid == '1') {
$status = img_picto($langs->trans((string) $charge->status), 'statut4');
} else {
$label = $langs->trans("Message").": ".$charge->failure_message."<br>";
$label .= $langs->trans("Network").": ".$charge->outcome->network_status."<br>";
$label .= $langs->trans("Status").": ".$langs->trans((string) $charge->outcome->seller_message);
$status = $form->textwithpicto(img_picto($langs->trans((string) $charge->status), 'statut8'), $label, -1);
}
if (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'card') {
$type = $langs->trans("card");
} elseif (isset($charge->source->type) && $charge->source->type == 'card') {
$type = $langs->trans("card");
} elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'three_d_secure') {
$type = $langs->trans("card3DS");
} elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'sepa_debit') {
$type = $langs->trans("sepadebit");
} elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'ideal') {
$type = $langs->trans("iDEAL");
}
if (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'card') {
$type = $langs->trans("card");
} elseif (isset($charge->source->type) && $charge->source->type == 'card') {
$type = $langs->trans("card");
} elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'three_d_secure') {
$type = $langs->trans("card3DS");
} elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'sepa_debit') {
$type = $langs->trans("sepadebit");
} elseif (isset($charge->payment_method_details->type) && $charge->payment_method_details->type == 'ideal') {
$type = $langs->trans("iDEAL");
}
// Why this ?
/*if (!empty($charge->payment_intent)) {
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent);
} else {
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent, array("stripe_account" => $stripeacc));
}
}*/
// Why this ?
/*if (!empty($charge->payment_intent)) {
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent);
} else {
$charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent, array("stripe_account" => $stripeacc));
}
}*/
// The metadata FULLTAG is defined by the online payment page
$FULLTAG = $charge->metadata->FULLTAG;
// The metadata FULLTAG is defined by the online payment page
$FULLTAG = $charge->metadata->FULLTAG;
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG, '.', '=');
// Load origin object according to metadata
if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0) {
$societestatic->fetch($tmparray['CUS']);
} elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) {
$societestatic->fetch($charge->metadata->dol_thirdparty_id);
} else {
$societestatic->id = 0;
}
if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0) {
$memberstatic->fetch($tmparray['MEM']);
} else {
$memberstatic->id = 0;
}
// Save into $tmparray all metadata
$tmparray = dolExplodeIntoArray($FULLTAG, '.', '=');
// Load origin object according to metadata
if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0) {
$societestatic->fetch($tmparray['CUS']);
} elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) {
$societestatic->fetch($charge->metadata->dol_thirdparty_id);
} else {
$societestatic->id = 0;
}
if (!empty($tmparray['MEM']) && $tmparray['MEM'] > 0) {
$memberstatic->fetch($tmparray['MEM']);
} else {
$memberstatic->id = 0;
}
print '<tr class="oddeven">';
print '<tr class="oddeven">';
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
} else {
$connect = '';
}
if (!empty($stripeacc)) {
$connect = $stripeacc.'/';
} else {
$connect = '';
}
// Ref
$url = 'https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id;
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id;
}
print "<td>";
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id."</a>";
if ($charge->payment_intent) {
print '<br><span class="opacitymedium">'.$charge->payment_intent.'</span>';
}
print "</td>\n";
// Ref
$url = 'https://dashboard.stripe.com/'.$connect.'test/payments/'.$charge->id;
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id;
}
print "<td>";
print "<a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id."</a>";
if ($charge->payment_intent) {
print '<br><span class="opacitymedium">'.$charge->payment_intent.'</span>';
}
print "</td>\n";
// Stripe customer
print "<td>";
if (isModEnabled('stripe') && !empty($stripeacc)) {
$connect = $stripeacc.'/';
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$charge->customer;
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$charge->customer;
}
if (!empty($charge->customer)) {
print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.'</a>';
}
print "</td>\n";
// Stripe customer
print "<td>";
if (isModEnabled('stripe') && !empty($stripeacc)) {
$connect = $stripeacc.'/';
}
$url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$charge->customer;
if ($servicestatus) {
$url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$charge->customer;
}
if (!empty($charge->customer)) {
print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.'</a>';
}
print "</td>\n";
// Link
print "<td>";
if ($societestatic->id > 0) {
print $societestatic->getNomUrl(1);
} elseif ($memberstatic->id > 0) {
print $memberstatic->getNomUrl(1);
}
print "</td>\n";
// Link
print "<td>";
if ($societestatic->id > 0) {
print $societestatic->getNomUrl(1);
} elseif ($memberstatic->id > 0) {
print $memberstatic->getNomUrl(1);
}
print "</td>\n";
// Origin
print "<td>";
if ($charge->metadata->dol_type == "order" || $charge->metadata->dol_type == "commande") {
$object = new Commande($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$object->id."'>".img_picto('', 'order')." ".$object->ref."</a>";
// Origin
print "<td>";
if ($charge->metadata->dol_type == "order" || $charge->metadata->dol_type == "commande") {
$object = new Commande($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$object->id."'>".img_picto('', 'order')." ".$object->ref."</a>";
} else {
print $FULLTAG;
}
} elseif ($charge->metadata->dol_type == "invoice" || $charge->metadata->dol_type == "facture") {
$object = new Facture($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'bill')." ".$object->ref."</a>";
} else {
print $FULLTAG;
}
} else {
print $FULLTAG;
}
} elseif ($charge->metadata->dol_type == "invoice" || $charge->metadata->dol_type == "facture") {
$object = new Facture($db);
$object->fetch($charge->metadata->dol_id);
if ($object->id > 0) {
print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'bill')." ".$object->ref."</a>";
} else {
print $FULLTAG;
}
} else {
print $FULLTAG;
print "</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($charge->created, 'dayhour')."</td>\n";
// Type
print '<td>';
print $type;
print '</td>';
// Amount
print '<td class="right"><span class="amount">'.price(($charge->amount - $charge->amount_refunded) / 100, 0, '', 1, - 1, - 1, strtoupper($charge->currency))."</span></td>";
// Status
print '<td class="right">';
print $status;
print "</td>\n";
print "</tr>\n";
$i++;
}
print "</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($charge->created, 'dayhour')."</td>\n";
// Type
print '<td>';
print $type;
print '</td>';
// Amount
print '<td class="right"><span class="amount">'.price(($charge->amount - $charge->amount_refunded) / 100, 0, '', 1, - 1, - 1, strtoupper($charge->currency))."</span></td>";
// Status
print '<td class="right">';
print $status;
print "</td>\n";
print "</tr>\n";
$i++;
}
print '</table>';