Exemplo n.º 1
0
if (!isset($_GET['id_client']) or !isset($_GET['id_invoice'])) {
    echo "Missing arguments";
    exit;
}
if (!is_numeric($_GET['id_client']) or !is_numeric($_GET['id_invoice'])) {
    echo "Wrong arguments";
    exit;
}
$Client = new Client();
# check client and invoice
if (!$Client->exists($_GET['id_client'])) {
    echo _("This client doesn't exist");
    exit;
}
$Invoice = new Facture();
if ($Invoice->exists($_GET['id_invoice'])) {
    $inv = $Invoice->getInfos($_GET['id_invoice']);
    if ($inv->id_client != $_GET['id_client']) {
        echo _("This invoice isn't yours!");
        exit;
    }
    $Client = new Client($_GET['id_client']);
}
#site
$result = mysql_query("SELECT value FROM webfinance_pref WHERE type_pref='societe' AND owner=-1") or wf_mysqldie();
list($value) = mysql_fetch_array($result);
mysql_free_result($result);
$company = unserialize(base64_decode($value));
$site = "webfinance.dev.jexiste.org";
if (!empty($company->wf_url) and strlen($company->wf_url) > 3) {
    $site = preg_replace('/^http:\\/\\//i', '', $company->wf_url);
Exemplo n.º 2
0
    }
    /* else */
    /* $_SESSION['message'] = _('Invoice updated'); */
    if ($type_doc == "facture" || $type_doc == "devis" && $is_paye == "on") {
        $Facture->updateTransaction($_POST['id_facture'], $type_prev);
        /* $_SESSION['message'] .=  "<br>"._('Transaction updated'); */
    }
    header("Location: edit_facture.php?id_facture=" . $_POST['id_facture']);
    exit;
}
if ($action == "delete_facture") {
    $id_client = "";
    // delete_facture
    // Suppression d'une facture
    $Facture = new Facture();
    if (is_numeric($_GET['id_facture']) and $Facture->exists($_GET['id_facture'])) {
        $facture = $Facture->getInfos($_GET['id_facture']);
        logmessage(_("Delete invoice") . " #{$facture->num_facture} for client:{$facture->id_client}", $facture->id_client);
        $id_client = $facture->id_client;
        mysql_query("DELETE FROM webfinance_invoices WHERE id_facture=" . $_GET['id_facture']) or wf_mysqldie();
        $_SESSION['message'] = _('Invoice deleted');
        //mysql_query("DELETE FROM webfinance_invoice_rows WHERE id_facture=".$_GET['id_facture']); <- ON DELETE CASCADE
        mysql_query("DELETE FROM webfinance_transactions WHERE id_invoice=" . $_GET['id_facture'] . " AND type<>'real'") or wf_mysqldie();
        $_SESSION['message'] .= "<br/>" . _('Transaction deleted');
    }
    header("Location: fiche_prospect.php?onglet=billing&tab=billing&id={$id_client}");
    exit;
}
if ($action == "duplicate") {
    extract($_GET);
    $Invoice = new Facture();
Exemplo n.º 3
0
   (at your option) any later version.

    Webfinance is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Webfinance; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
include "../inc/main.php";
must_login();
$roles = 'manager,employee';
include "nav.php";
$Invoice = new Facture();
if (!isset($_GET['id']) or !is_numeric($_GET['id']) or !$Invoice->exists($_GET['id'])) {
    echo "Invalid invoice id";
    exit(1);
}
$facture = $Invoice->getInfos($_GET['id']);
if ($facture->is_paye) {
    echo "Invoice has already been paid";
    exit(1);
}
// Plan the invoice to be debited
mysql_query("INSERT INTO direct_debit_row " . "SET invoice_id = {$_GET['id']}, " . "    state='todo'") or die(mysql_error());
// Flag invoice as paid
$Invoice->setPaid($_GET['id']);
header("Location: ../prospection/edit_facture.php?id_facture={$_GET['id']}");
exit;
Exemplo n.º 4
0
if (!isset($id_client) or !isset($id_invoice)) {
    echo "Missing arguments";
    exit;
}
if (!is_numeric($id_client) or !is_numeric($id_invoice)) {
    echo "Wrong arguments";
    exit;
}
$Client = new Client();
# check client and invoice
if (!$Client->exists($id_client)) {
    echo _("This client doesn't exist");
    exit;
}
$Invoice = new Facture();
if ($Invoice->exists($id_invoice)) {
    $inv = $Invoice->getInfos($id_invoice);
    if ($inv->id_client != $id_client) {
        echo _("This invoice isn't yours!");
        exit;
    }
    if ($inv->is_paye > 0) {
        echo _("This invoice is already paid.");
        exit;
    }
    $Client = new Client($id_client);
}
//insert the transation in the db
$ref_cmd = "WEBFINANCE;" . random_int(10);
$r = mysql_query("INSERT INTO webfinance_payment SET id_invoice={$inv->id_facture}, " . "email='" . $Client->email . "' , " . "reference='" . $ref_cmd . "' , " . "state='pending', " . "amount='{$inv->nice_total_ttc}' , " . "currency='EUR' , " . "id_payment_type='" . $paypal_params['id_payment_type'] . "' , " . "date=NOW() ") or die('212' . mysql_error());
?>