Fix: Bad use of fetch_lines

Conflicts:
	htdocs/comm/propal.php
	htdocs/contrat/fiche.php
	htdocs/opensurvey/class/opensurveysondage.class.php
This commit is contained in:
Laurent Destailleur 2014-09-04 19:03:48 +02:00
parent cd00ec29bf
commit 643fc6c61f
13 changed files with 68 additions and 38 deletions

View File

@ -269,10 +269,12 @@ else if ($action == 'add' && $user->rights->commande->creer) {
if ($ret < 0)
$error ++;
if (! $error) {
if (! $error)
{
$object_id = $object->create($user);
if ($object_id > 0) {
if ($object_id > 0)
{
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
$classname = ucfirst($subelement);
@ -280,15 +282,20 @@ else if ($action == 'add' && $user->rights->commande->creer) {
dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
$result = $srcobject->fetch($object->origin_id);
if ($result > 0) {
if ($result > 0)
{
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
$lines = $srcobject->fetch_lines();
{
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
$fk_parent_line = 0;
$num = count($lines);
for($i = 0; $i < $num; $i ++) {
for($i = 0; $i < $num; $i ++)
{
$label = (! empty($lines [$i]->label) ? $lines [$i]->label : '');
$desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle);
$product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0);

View File

@ -97,7 +97,7 @@ if (($action == 'create' || $action == 'add') && empty($mesgs))
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$langs->load('bills');
$langs->load('products');
$langs->load('main');
@ -213,13 +213,17 @@ if (($action == 'create' || $action == 'add') && empty($mesgs))
$result=$objectsrc->fetch($orders_id[$ii]);
if ($result > 0)
{
if ($closeOrders)
if ($closeOrders)
{
$objectsrc->classifyBilled();
$objectsrc->setStatut(3);
}
$lines = $objectsrc->lines;
if (empty($lines) && method_exists($objectsrc,'fetch_lines')) $lines = $objectsrc->fetch_lines();
if (empty($lines) && method_exists($objectsrc, 'fetch_lines'))
{
$objectsrc->fetch_lines();
$lines = $objectsrc->lines;
}
$fk_parent_line=0;
$num=count($lines);
for ($i=0;$i<$num;$i++)

View File

@ -924,7 +924,11 @@ else if ($action == 'add' && $user->rights->facture->creer)
if ($result > 0)
{
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject, 'fetch_lines')) $lines = $srcobject->fetch_lines();
if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
{
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
$fk_parent_line=0;
$num=count($lines);

View File

@ -250,7 +250,11 @@ if ($action == 'add' && $user->rights->contrat->creer)
{
$srcobject->fetch_thirdparty();
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
if (empty($lines) && method_exists($srcobject,'fetch_lines'))
{
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
$fk_parent_line=0;
$num=count($lines);
@ -337,10 +341,10 @@ if ($action == 'add' && $user->rights->contrat->creer)
}
else
{
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$result = $object->create($user);
if ($result > 0)
{
@ -715,7 +719,7 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
$error ++;
if (! $error) {
$result = $object->insertExtraFields();
if ($result < 0) {
$error ++;
@ -948,7 +952,7 @@ if ($action == 'create')
// Other attributes
$parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
// Other attributes
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
print $object->showOptionals($extrafields, 'edit');
@ -1112,7 +1116,7 @@ else
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
$res = $object->fetch_optionals($object->id, $extralabels);
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
foreach ($extrafields->attribute_label as $key => $label) {
@ -1132,16 +1136,16 @@ else
if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
$value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
}
if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) {
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formcontract">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="attribute" value="' . $key . '">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print $extrafields->showInputField($key, $value);
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
@ -1153,9 +1157,9 @@ else
}
}
}
print "</table>";

View File

@ -112,7 +112,6 @@ if ($action == 'add')
$classname = ucfirst($object->origin);
$objectsrc = new $classname($db);
$objectsrc->fetch($object->origin_id);
//$object->fetch_lines();
$object->socid = $objectsrc->socid;
$object->ref_customer = $objectsrc->ref_client;
@ -717,7 +716,6 @@ if ($action == 'create')
* Lignes de commandes
*/
//$lines = $object->fetch_lines(1);
$numAsked = count($object->lines);
print '<script type="text/javascript" language="javascript">

View File

@ -973,9 +973,9 @@ class Fichinter extends CommonObject
}
/**
* Load array lines
* Load array lines ->lines
*
* @return int <0 if Ko, >0 if OK
* @return int <0 if KO, >0 if OK
*/
function fetch_lines()
{

View File

@ -212,7 +212,11 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
{
$srcobject->fetch_thirdparty();
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
if (empty($lines) && method_exists($srcobject,'fetch_lines'))
{
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
$fk_parent_line=0;
$num=count($lines);
@ -913,7 +917,11 @@ if ($action == 'create')
$classname = ucfirst($subelement);
$objectsrc = new $classname($db);
$objectsrc->fetch(GETPOST('originid'));
if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines();
if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines'))
{
$objectsrc->fetch_lines();
$lines = $objectsrc->lines;
}
$objectsrc->fetch_thirdparty();
$projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:'');

View File

@ -355,7 +355,11 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
if ($result > 0)
{
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
if (empty($lines) && method_exists($srcobject,'fetch_lines'))
{
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
$num=count($lines);
for ($i = 0; $i < $num; $i++)

View File

@ -148,7 +148,7 @@ class Livraison extends CommonObject
{
$commande = new Commande($this->db);
$commande->id = $this->commande_id;
$this->lines = $commande->fetch_lines();
$commande->fetch_lines();
}

View File

@ -185,7 +185,7 @@ if ($action == 'builddoc') // En get ou en post
$object = new Livraison($db);
$object->fetch($id);
$object->fetch_thirdparty();
// Save last template used to generate document
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
@ -317,7 +317,8 @@ if ($action == 'create')
*/
print '<br><table class="noborder" width="100%">';
$lines = $commande->fetch_lines(1);
$commande->fetch_lines(1);
$lines = $commande->lines;
// Lecture des livraisons deja effectuees
$commande->livraison_array();
@ -515,7 +516,7 @@ else
if (($delivery->origin == 'shipment' || $delivery->origin == 'expedition') && $delivery->origin_id > 0)
{
$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/liste.php">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="20%">'.$langs->trans("RefSending").'</td>';
print '<td colspan="3">';
@ -523,8 +524,8 @@ else
//print $form->showrefnav($expedition, 'refshipment', $linkback, 1, 'ref', 'ref');
print $form->showrefnav($expedition, 'refshipment', $linkback, 0, 'ref', 'ref');
print '</td></tr>';
}
}
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">'.$delivery->ref.'</td></tr>';

View File

@ -392,7 +392,7 @@ class Opensurveysondage extends CommonObject
/**
* Return array of lines
*
* @return array Array of lines
* @return int <0 if KO, >0 if OK
*/
function fetch_lines()
{
@ -418,7 +418,7 @@ class Opensurveysondage extends CommonObject
$this->lines=$ret;
return $this->lines;
return count($this->lines);
}
/**

View File

@ -43,7 +43,7 @@ $object=new Opensurveysondage($db);
$result=$object->fetch(0,$numsondage);
if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
$nblignes=count($object->fetch_lines());
$nblignes=$object->fetch_lines();
//If the survey has not yet finished, then it can be modified
$canbemodified = ($object->date_fin > dol_now());

View File

@ -42,7 +42,7 @@ $object=new Opensurveysondage($db);
$result=$object->fetch(0,$numsondage);
if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
$nblignes=count($object->fetch_lines());
$nblignes=$object->fetch_lines();
/*