Exemplo n.º 1
0
            } else {
                $error++;
                $mesg = '<div class="error">' . $soc->error . '</div>';
            }
        }
    } else {
        $mesg = '<div class="error">' . $langs->trans("ErrorFieldFormat", $langs->trans("NewGlobalDiscount")) . '</div>';
    }
}
if (GETPOST("action") == 'confirm_remove' && GETPOST("confirm") == 'yes') {
    //if ($user->rights->societe->creer)
    //if ($user->rights->facture->creer)
    $db->begin();
    $discount = new DiscountAbsolute($db);
    $result = $discount->fetch(GETPOST("remid"));
    $result = $discount->delete($user);
    if ($result > 0) {
        $db->commit();
        header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . GETPOST('id', 'int'));
        // To avoid pb whith back
        exit;
    } else {
        $mesg = '<div class="error">' . $discount->error . '</div>';
        $db->rollback();
    }
}
/*
 * View
 */
$form = new Form($db);
$facturestatic = new Facture($db);
Exemplo n.º 2
0
    /**
     * testDiscountDelete
     *
     * @param	int		$id		Id of discount
     * @return	int
     *
     * @depends	testDiscountFetch
     * The depends says test is run only if previous is ok
     */
    public function testDiscountDelete($id)
    {
    	global $conf,$user,$langs,$db;
		$conf=$this->savconf;
		$user=$this->savuser;
		$langs=$this->savlangs;
		$db=$this->savdb;

		$localobject=new DiscountAbsolute($this->savdb);
    	$result=$localobject->fetch($id);
		$result=$localobject->delete($user);

		print __METHOD__." id=".$id." result=".$result."\n";
    	$this->assertLessThan($result, 0);
    	return $result;
    }