} //$result=restrictedArea($user,'produit'); $mesg = ''; /* * Actions */ // Add product to list if ($action == 'add') { $fac = new FactureFournisseur($db); $fac->fetch($id); $error = 0; for ($i = 0; $i < sizeof($fac->lines); $i++) { $object = new Labelprint($db); $object->fk_product = $fac->lines[$i]->fk_product; $object->qty = $fac->lines[$i]->qty; $result = $object->create($user); if (!$result) { $error++; } } if ($error) { $mesg = '<div class="error">' . $object->error . '</div>'; } else { $mesg = '<font class="ok">' . $langs->trans("LinesAdded") . '</font>'; } } // Print list if ($action == 'print') { /*$pdf=new pdfLabel(); $pdf->createPdf(); /*$res = $pdf->createPdf();
/** * Load an object from its id and create a new one in database * @param int $fromid Id of object to clone * @return int New id of clone */ function createFromClone($fromid) { global $user, $langs; $error = 0; $object = new Labelprint($this->db); $this->db->begin(); // Load source object $object->fetch($fromid); $object->id = 0; $object->statut = 0; // Clear fields // ... // Create clone $result = $object->create($user); // Other options if ($result < 0) { $this->error = $object->error; $error++; } // End if (!$error) { $this->db->commit(); return $object->id; } else { $this->db->rollback(); return -1; } }