Example #1
0
 /**
  * testFactureCreate
  *
  * @return int
  */
 public function testFactureRecCreate()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobjectinv = new Facture($this->savdb);
     $localobjectinv->initAsSpecimen();
     $localobjectinv->create($user);
     $localobject = new FactureRec($this->savdb);
     $localobject->initAsSpecimen();
     $result = $localobject->create($user, $localobjectinv->id);
     $this->assertLessThan($result, 0);
     print __METHOD__ . " result=" . $result . "\n";
     return $result;
 }
Example #2
0
$object = new FactureRec($db);
/*
 * Actions
 */
// Create predefined invoice
if ($action == 'add') {
    if (!GETPOST('titre')) {
        setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors');
        $action = "create";
        $error++;
    }
    if (!$error) {
        $object->titre = GETPOST('titre', 'alpha');
        $object->note_private = GETPOST('note_private');
        $object->usenewprice = GETPOST('usenewprice');
        if ($object->create($user, $id) > 0) {
            $id = $object->id;
            $action = '';
        } else {
            setEventMessages($object->error, $object->errors, 'errors');
            $action = "create";
        }
    }
}
// Delete
if ($action == 'delete' && $user->rights->facture->supprimer) {
    $object->fetch($id);
    $object->delete();
    $id = 0;
}
/*
Example #3
0
$offset = $limit * $page;
if ($sortorder == "") {
    $sortorder = "DESC";
}
if ($sortfield == "") {
    $sortfield = "f.datef";
}
/*
 * Actions
 */
// Create predefined invoice
if ($action == 'add') {
    $facturerec = new FactureRec($db);
    $facturerec->titre = $_POST["titre"];
    $facturerec->note = $_POST["comment"];
    if ($facturerec->create($user, $facid) > 0) {
        $facid = $facturerec->id;
        $action = '';
    } else {
        $action = "create";
        $mesg = '<div class="error">' . $facturerec->error . '</div>';
    }
}
// Suppression
if ($action == 'delete' && $user->rights->facture->supprimer) {
    $facrec = new FactureRec($db);
    $facrec->fetch($facid);
    $facrec->delete();
    $facid = 0;
}
/*