Skip to content

Commit

Permalink
Qual: Fix (propal|facture|contrat|fichinter)/card, commonobject, file…
Browse files Browse the repository at this point in the history
…s.lib/card_presend.tpl

# Qual: Fix (propal|facture|contrat|fichinter)/card, commonobject, files.lib/card_presend.tpl

Fix phan notices in these files
  • Loading branch information
mdeweerd committed Sep 23, 2024
1 parent 158de3d commit c627d85
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 83 deletions.
46 changes: 22 additions & 24 deletions dev/tools/phan/baseline.txt

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions htdocs/comm/propal/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@
$element = $subelement = 'contrat';
}
if ($element == 'inter') {
$element = $subelement = 'ficheinter';
$element = $subelement = 'fichinter';
}
if ($element == 'shipping') {
$element = $subelement = 'expedition';
Expand All @@ -568,6 +568,7 @@

$classname = ucfirst($subelement);
$srcobject = new $classname($db);
'@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject'; // Can be other class, but CommonObject is too generic

dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
$result = $srcobject->fetch($object->origin_id);
Expand Down Expand Up @@ -1839,6 +1840,7 @@

$classname = ucfirst($subelement);
$objectsrc = new $classname($db);
'@phan-var-force Commande|Propal|Contrat|Expedition $objectsrc'; // Can be other class, but CommonObject is too generic
$objectsrc->fetch($originid);
if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) {
$objectsrc->fetch_lines();
Expand Down Expand Up @@ -1956,7 +1958,7 @@
} else {
print '<td class="valuefieldcreate">';
$filter = '((s.client:IN:1,2,3) AND (s.status:=:1))';
print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company('', 'socid', $filter, 'SelectThirdParty', 1, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx');
print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company('', 'socid', $filter, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 maxwidth500 widthcentpercentminusxx');
// reload page to retrieve customer information
if (!getDolGlobalString('RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED')) {
print '<script>
Expand Down Expand Up @@ -2289,7 +2291,7 @@
$formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOSTINT('socid'), 'socid', $filter, '', 0, 0, null, 0, 'maxwidth300')),
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOSTINT('socid'), 'socid', $filter, '', 0, 0, array(), 0, 'maxwidth300')),
array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans('PuttingPricesUpToDate'), 'value' => 0),
array('type' => 'checkbox', 'name' => 'update_desc', 'label' => $langs->trans('PuttingDescUpToDate'), 'value' => 0),
);
Expand Down Expand Up @@ -2324,6 +2326,7 @@

if (array_key_exists('facture', $object->linkedObjects)) {
foreach ($object->linkedObjects['facture'] as $invoice) {
'@phan-var-force Facture $invoice';
if ($invoice->type == Facture::TYPE_DEPOSIT) {
$eligibleForDepositGeneration = false;
break;
Expand All @@ -2337,6 +2340,7 @@

if (array_key_exists('facture', $order->linkedObjects)) {
foreach ($order->linkedObjects['facture'] as $invoice) {
'@phan-var-force Facture $invoice';
if ($invoice->type == Facture::TYPE_DEPOSIT) {
$eligibleForDepositGeneration = false;
break 2;
Expand Down Expand Up @@ -2585,8 +2589,8 @@

print '<tr><td>'.$langs->trans('Discounts').'</td><td>';

$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote);
$absolute_discount = $soc->getAvailableDiscounts(null, $filterabsolutediscount);
$absolute_creditnote = $soc->getAvailableDiscounts(null, $filtercreditnote);
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');

Expand Down Expand Up @@ -3223,7 +3227,7 @@
print $formfile->showdocuments('propal', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object);

// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('propal'));
$linktoelem = $form->showLinkToObjectBlock($object, array(), array('propal'));

$compatibleImportElementsList = false;
if ($user->hasRight('propal', 'creer') && $object->statut == Propal::STATUS_DRAFT) {
Expand Down
7 changes: 4 additions & 3 deletions htdocs/compta/facture/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@
$element = $subelement = 'contrat';
}
if ($element == 'inter') {
$element = $subelement = 'ficheinter';
$element = $subelement = 'fichinter';
}
if ($element == 'shipping') {
$element = $subelement = 'expedition';
Expand Down Expand Up @@ -1991,7 +1991,8 @@
$line->fk_prev_id = $line->id;
$line->fetch_optionals();
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) {
$line->situation_percent = $line->get_allprev_progress($object->id);; // get good progress including credit note
$line->situation_percent = $line->get_allprev_progress($object->id);
; // get good progress including credit note
} else {
$line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note
}
Expand Down Expand Up @@ -2128,7 +2129,7 @@
$remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
$remise_percent = str_replace('*', '', $remise_percent);
foreach ($object->lines as $line) {
$tvatx= $line->tva_tx;
$tvatx = $line->tva_tx;
if (!empty($line->vat_src_code)) {
$tvatx .= ' ('.$line->vat_src_code.')';
}
Expand Down
23 changes: 17 additions & 6 deletions htdocs/contrat/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@


$datecontrat = '';
$moreparam = '';
$note_public = '';
$note_private = '';
$usehm = (getDolGlobalString('MAIN_USE_HOURMIN_IN_DATE_RANGE') ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0);

// Security check
Expand Down Expand Up @@ -318,6 +321,7 @@

$classname = ucfirst($subelement);
$srcobject = new $classname($db);
'@phan-var-force Commande|Propal|Facture $srcobject'; // Can be other class, but CommonObject is too Generic

dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
$result = $srcobject->fetch($object->origin_id);
Expand Down Expand Up @@ -519,6 +523,8 @@
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));

$price_base_type = '';
$price_min = '';
// Ecrase $tva_tx par celui du produit. TODO Remove this once vat selection is open
// Get and check minimum price
if ($idprod > 0) {
Expand Down Expand Up @@ -737,7 +743,9 @@
}
$objectline->fetch_optionals();

$objectline->oldcopy = dol_clone($objectline, 2);
$objectline->oldcopy = dol_clone($objectline, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
} else {
$objectline = null;
}

$db->begin();
Expand Down Expand Up @@ -1117,8 +1125,10 @@
$module = substr($module, 0, dol_strlen($module) - 4);
}
$result = dol_include_once('/core/modules/contract/'.$module.'.php');
$modCodeContract = null;
if ($result > 0) {
$modCodeContract = new $module();
'@phan-var-force ModelNumRefContracts $modCodeContract';
}

// Create
Expand Down Expand Up @@ -1160,6 +1170,7 @@

$classname = ucfirst($subelement);
$objectsrc = new $classname($db);
'@phan-var-force Commande|Propal|Facture $objectsrc';
$objectsrc->fetch($originid);
if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) {
$objectsrc->fetch_lines();
Expand All @@ -1182,8 +1193,8 @@
}
} else {
$projectid = GETPOSTINT('projectid');
$note_private = GETPOST("note_private");
$note_public = GETPOST("note_public");
$note_private = GETPOST("note_private", "alpha");
$note_public = GETPOST("note_public", "alpha");
}

$object->date_contrat = dol_now();
Expand Down Expand Up @@ -1228,7 +1239,7 @@
} else {
print '<td>';
print img_picto('', 'company', 'class="pictofixedwidth"');
print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300 widthcentpercentminusxx maxwidth500');
print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300 widthcentpercentminusxx maxwidth500');
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>';
print '</td>';
}
Expand Down Expand Up @@ -1444,7 +1455,7 @@
$morehtmlref .= $object->ref;
} else {
$morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 3);
$morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 2);
$morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', null, 2);
}

$morehtmlref .= '<div class="refidno">';
Expand Down Expand Up @@ -1672,7 +1683,7 @@
$description = ''; // Already added into main visible desc
}

print $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 3, (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : ''));
print $form->textwithtooltip($text, $description, 3, 0, 0, $cursorline, 3, (!empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : ''));

print '</td>';
} else {
Expand Down
Loading

0 comments on commit c627d85

Please sign in to comment.