/**
  * update
  *
  * @param   User    $fuser      User
  * @return  int                 <0 if KO, >0 if OK
  */
 function update($fuser)
 {
     global $fuser, $langs, $conf;
     $error = 0;
     // Clean parameters
     $this->comments = trim($this->comments);
     $this->vatrate = price2num($this->vatrate);
     $this->db->begin();
     // Mise a jour ligne en base
     $sql = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det SET";
     $sql .= " comments='" . $this->db->escape($this->comments) . "'";
     $sql .= ",value_unit=" . $this->value_unit . "";
     $sql .= ",qty=" . $this->qty . "";
     $sql .= ",date='" . $this->db->idate($this->date) . "'";
     $sql .= ",total_ht=" . $this->total_ht . "";
     $sql .= ",total_tva=" . $this->total_tva . "";
     $sql .= ",total_ttc=" . $this->total_ttc . "";
     $sql .= ",tva_tx=" . $this->vatrate;
     if ($this->fk_c_type_fees) {
         $sql .= ",fk_c_type_fees=" . $this->fk_c_type_fees;
     } else {
         $sql .= ",fk_c_type_fees=null";
     }
     if ($this->fk_projet) {
         $sql .= ",fk_projet=" . $this->fk_projet;
     } else {
         $sql .= ",fk_projet=null";
     }
     $sql .= " WHERE rowid = " . $this->rowid;
     dol_syslog("ExpenseReportLine::update sql=" . $sql);
     $resql = $this->db->query($sql);
     if ($resql) {
         $tmpparent = new ExpenseReport($this->db);
         $result = $tmpparent->fetch($this->fk_expensereport);
         if ($result > 0) {
             $result = $tmpparent->update_price();
             if ($result < 0) {
                 $error++;
                 $this->error = $tmpparent->error;
                 $this->errors = $tmpparent->errors;
             }
         } else {
             $error++;
             $this->error = $tmpparent->error;
             $this->errors = $tmpparent->errors;
         }
     } else {
         $error++;
         dol_print_error($this->db);
     }
     if (!$error) {
         $this->db->commit();
         return 1;
     } else {
         $this->error = $this->db->lasterror();
         dol_syslog("ExpenseReportLine::update Error " . $this->error, LOG_ERR);
         $this->db->rollback();
         return -2;
     }
 }
Exemplo n.º 2
0
                dol_fiche_end();
            }
            // end edit or not edit
        } else {
            dol_print_error($db);
        }
    }
    //fin si id > 0
}
/*
 * Barre d'actions
 */
print '<div class="tabsAction">';
if ($action != 'create' && $action != 'edit') {
    $object = new ExpenseReport($db);
    $object->fetch($id, $ref);
    /* Si l'état est "Brouillon"
     *	ET user à droit "creer/supprimer"
     *	ET fk_user_author == user courant
     * 	Afficher : "Enregistrer" / "Modifier" / "Supprimer"
     */
    if ($user->rights->expensereport->creer && $object->fk_statut == 0) {
        if ($object->fk_user_author == $user->id) {
            // Modify
            print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $object->id . '">' . $langs->trans('Modify') . '</a>';
            // Validate
            if (count($object->lines) > 0 || count($object->lignes) > 0) {
                print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=save&id=' . $object->id . '">' . $langs->trans('ValidateAndSubmit') . '</a>';
            }
            if ($user->rights->expensereport->supprimer) {
                // Delete
Exemplo n.º 3
0
			{
				$tmp=explode('_',$elementarray[$i]);
				$idofelement=$tmp[0];
				$idofelementuser=$tmp[1];

				$element->fetch($idofelement);
				if ($idofelementuser) $elementuser->fetch($idofelementuser);

				if ($tablename != 'expensereport_det')
				{
					$element->fetch_thirdparty();
				}
				else
				{
					$expensereport=new ExpenseReport($db);
					$expensereport->fetch($element->fk_expensereport);
				}

				//print 'xxx'.$tablename;
				//print $classname;

				if ($breakline && $saved_third_id != $element->thirdparty->id)
				{
					print $breakline;
					$var = true;

					$saved_third_id = $element->thirdparty->id;
					$breakline = '';

					$total_ht_by_third=0;
					$total_ttc_by_third=0;
Exemplo n.º 4
0
 print '<br><table class="noborder" width="100%">';
 print '<tr class="liste_titre">';
 print '<td>' . $langs->trans('ExpenseReport') . '</td>';
 print '<td align="right">' . $langs->trans('ExpectedToPay') . '</td>';
 print '<td align="center">' . $langs->trans('Status') . '</td>';
 print '<td align="right">' . $langs->trans('PayedByThisPayment') . '</td>';
 print "</tr>\n";
 if ($num > 0) {
     $var = True;
     while ($i < $num) {
         $objp = $db->fetch_object($resql);
         $var = !$var;
         print '<tr ' . $bc[$var] . '>';
         // Ref
         print '<td>';
         $expensereport->fetch($objp->did);
         print $expensereport->getNomUrl(1);
         print "</td>\n";
         // Expected to pay
         print '<td align="right">' . price($objp->total_ttc) . '</td>';
         // Status
         print '<td align="center">' . $expensereport->getLibStatut(4, $objp->amount) . '</td>';
         // Amount paid
         print '<td align="right">' . price($objp->amount) . '</td>';
         print "</tr>\n";
         if ($objp->paid == 1) {
             $disable_delete = 1;
         }
         $total = $total + $objp->amount;
         $i++;
     }
Exemplo n.º 5
0
        $sql .= " WHERE rowid = {$idTrip}";
        $resql = $db->query($sql);
        if ($result) {
            Header("Location: " . $_SERVER["PHP_SELF"] . "?account=" . $idAccount);
            exit;
        } else {
            dol_print_error($db);
        }
    } else {
        dol_print_error($db, $acct->error);
    }
}
if ($_GET["action"] == 'confirm_account_to_ndf' && $_GET["confirm"] == "yes") {
    $idTrip = $_GET['idTrip'];
    $expensereport = new ExpenseReport($db);
    $expensereport->fetch($idTrip, $user);
    $sql = "DELETE FROM " . MAIN_DB_PREFIX . "bank";
    $sql .= " WHERE label LIKE '%" . $expensereport->ref . "%'";
    $resql = $db->query($sql);
    if ($resql > 0) {
        $sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport as d";
        $sql .= " SET integration_compta = 0, fk_bank_account = 0";
        $sql .= " WHERE rowid = {$idTrip}";
        $resql = $db->query($sql);
        if ($result) {
            Header("Location: " . $_SERVER["PHP_SELF"] . "?account=" . $idAccount);
            exit;
        } else {
            dol_print_error($db);
        }
    } else {
Exemplo n.º 6
0
            } else {
                $db->rollback();
            }
        }
    }
    $_GET["action"] = 'create';
}
/*
 * View
 */
llxHeader();
$form = new Form($db);
// Form to create expense report payment
if (GETPOST("action") == 'create') {
    $expensereport = new ExpenseReport($db);
    $expensereport->fetch($chid);
    $total = $expensereport->total_ttc;
    print load_fiche_titre($langs->trans("DoPayment"));
    if ($mesg) {
        print "<div class=\"error\">{$mesg}</div>";
    }
    print '<form name="add_payment" action="' . $_SERVER['PHP_SELF'] . '" method="post">';
    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    print '<input type="hidden" name="id" value="' . $chid . '">';
    print '<input type="hidden" name="chid" value="' . $chid . '">';
    print '<input type="hidden" name="action" value="add_payment">';
    dol_fiche_head();
    print '<table cellspacing="0" class="border" width="100%" cellpadding="2">';
    print '<tr class="liste_titre"><td colspan="3">' . $langs->trans("ExpenseReport") . '</td>';
    print '<tr><td>' . $langs->trans("Ref") . '</td><td colspan="2"><a href="' . DOL_URL_ROOT . '/expensereport/card.php?id=' . $chid . '">' . $expensereport->ref . '</a></td></tr>';
    print '<tr><td>' . $langs->trans("Period") . '</td><td colspan="2">' . get_date_range($expensereport->date_debut, $expensereport->date_fin, "", $langs, 0) . '</td></tr>';
Exemplo n.º 7
0
 * 	\ingroup    expensereport
 * 	\brief      Page to show a trip information
 */
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/expensereport.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
$langs->load("trips");
// Security check
$id = GETPOST('id', 'int');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'expensereport', $id, '');
/*
 * View
 */
llxHeader();
if ($id) {
    $object = new ExpenseReport($db);
    $object->fetch($id);
    $object->info($id);
    $head = expensereport_prepare_head($object);
    dol_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip');
    print '<table width="100%"><tr><td>';
    dol_print_object_info($object);
    print '</td></tr></table>';
    print '</div>';
}
llxFooter();
$db->close();