Example #1
0
function date_params($_GET)
{
    $filter['end_date'] = "";
    $filter['start_date'] = "";
    $ts_start_date = "";
    $ts_end_date = "";
    extract($_GET);
    // If no date range is specified use "current month"
    $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    if (strftime("%Y") % 4 == 0 && strftime("%Y") % 100 != 0) {
        // Leap year
        $days_in_month[1] = 29;
    }
    if (isset($filter) && $filter['start_date'] != "" && $filter['end_date'] == "") {
        // If start_date is given and NOT end_date then we show transaction between
        // start_date and current date.
        $filter['end_date'] = strftime("%d/%m/%Y");
    }
    if (isset($filter) && $filter['start_date'] == "" && $filter['end_date'] != "") {
        // If end_date is given and NOT start_date then we show transaction from the
        // start of the company to end_date
        $result = WFO::SQL("SELECT value FROM webfinance_pref WHERE type_pref='societe' AND owner=-1");
        list($value) = mysql_fetch_array($result);
        mysql_free_result($result);
        $company = unserialize(base64_decode($value));
        $filter['start_date'] = $company->date_creation;
    }
    if (isset($filter) && $filter['start_date'] == "") {
        $filter['start_date'] = strftime("01/%m/%Y");
    }
    if ($filter['end_date'] == "") {
        $filter['end_date'] = strftime($days_in_month[strftime("%m") - 1] . "/%m/%Y");
    }
    preg_match("!([0-9]{2})/([0-9]{2})/([0-9]{4})!", $filter['start_date'], $foo);
    $ts_start_date = mktime(0, 0, 0, $foo['2'], $foo['1'], $foo['3']);
    preg_match("!([0-9]{2})/([0-9]{2})/([0-9]{4})!", $filter['end_date'], $foo);
    $ts_end_date = mktime(0, 0, 0, $foo['2'], $foo['1'], $foo['3']);
    // end date must be after begin date. If not reverse them
    if ($ts_start_date > $ts_end_date) {
        // Reverse : switch timestamps and formated dates
        $foo = $filter['start_date'];
        $filter['start_date'] = $filter['end_date'];
        $filter['end_date'] = $foo;
        $foo = $ts_start_date;
        $ts_start_date = $ts_end_date;
        $ts_end_date = $foo;
    }
    return array($ts_start_date, $ts_end_date, $filter['start_date'], $filter['end_date']);
}
Example #2
0
    }
    mysql_free_result($result);
    ?>
</select>
      </div>
      <div id="action_change_category" style="display: none;">
        <div style="display: block; float: left; width: 90px;"><?php 
    echo _('Category is');
    ?>
</div>&nbsp;<select name="action[id_category]">
        <option value="1"><?php 
    echo _('-- Choose --');
    ?>
</option>
        <?php 
    $result = WFO::SQL("SELECT id,name,color FROM webfinance_categories ORDER BY name");
    while ($cat = mysql_fetch_object($result)) {
        printf('<option value="%d">%s</option>', $cat->id, $cat->name);
    }
    mysql_free_result($result);
    ?>
        </select>
      </div>
    </td>
  </tr>
  <tr class="row_even">
    <td colspan="2" style="text-align: center"><input type="button" onclick="submitAction(this.form);" value="<?php 
    echo _('Apply this action');
    ?>
" /></td>
  </tr>
Example #3
0
     mysql_free_result($result);
     $nb++;
     $nb = sprintf("%04d", $nb);
     $num_facture = strftime("%y-{$nb}", $facture->timestamp_date_facture);
 }
 //date prev
 //   $date_prev=$facture->timestamp_date_facture+($_POST['type_prev'] * 86400 );
 //   $date_prev=date("Y-m-d",$date_prev);
 $res = mysql_query("SELECT count(*) FROM webfinance_invoices WHERE num_facture='{$num_facture}' AND id_facture<>{$id_facture} ") or wf_mysqldie();
 list($dup_num_inv) = mysql_fetch_array($res);
 mysql_free_result($res);
 // Generate periodic_next_deadline if needed
 if ($periodic_next_deadline == '0000-00-00' and $period != 'none') {
     $periodic_next_deadline = $Facture->nextDeadline(date('Y-m-d'), $period);
 }
 $q = sprintf("UPDATE webfinance_invoices SET " . "id_client=%d, " . "type_paiement='%s', " . "is_paye=%d, " . "%s  " . "is_envoye=%d, " . "%s  " . "ref_contrat='%s', " . "extra_top='%s', " . "extra_bottom='%s', " . "accompte='%s', " . "date_facture='%s', " . "type_doc='%s', " . "commentaire='%s', " . "id_type_presta=%d, " . "is_abandoned=%d, " . "id_compte=%d, " . "is_envoye=%d, " . "tax='%s', " . "exchange_rate='%s', " . "period='%s', " . "periodic_next_deadline='%s', " . "payment_method='%s', " . "delivery='%s' " . "%s " . "WHERE id_facture=%d", $id_client, $type_paiement, $is_paye == "on" ? 1 : 0, empty($date_paiement) ? 'date_paiement=NULL,' : "date_paiement='{$date_paiement}',", $is_envoye == "on" ? 1 : 0, empty($date_sent) ? 'date_sent=NULL,' : "date_sent='{$date_sent}',", $ref_contrat, mysql_real_escape_string($extra_top), mysql_real_escape_string($extra_bottom), WFO::stripMonetaryFormat($accompte), $date_facture, $type_doc, $commentaire, $id_type_presta, $is_abandoned == "on" ? 1 : 0, $id_compte, $is_envoye == "on" ? 1 : 0, $tax, empty($exchange_rate) ? 1 : $exchange_rate, $period, $periodic_next_deadline, $payment_method, $delivery, $dup_num_inv == 0 ? ",num_facture='{$num_facture}' " : "", $id_facture);
 mysql_query($q) or die(mysql_error() . "<br/> {$q}");
 logmessage(_("Save invoice") . " (#{$num_facture}) fa:" . $_POST['id_facture'] . " client:{$facture->id_client}", $facture->id_client, $_POST['id_facture']);
 if (empty($_POST['prix_ht_new'])) {
     $_POST['prix_ht_new'] = '0.0';
 }
 if (is_numeric($_POST['prix_ht_new']) && is_numeric($_POST['qtt_new']) && !empty($_POST['prix_ht_new']) && !empty($_POST['line_new'])) {
     // Enregistrement d'une nouvelle ligne de facturation pour une facture.
     $q = sprintf("INSERT INTO webfinance_invoice_rows (id_facture,description,prix_ht,qtt,ordre) " . "SELECT %d, '%s', %s, %s, if(max(ordre) is NULL, 1, max(ordre) + 1) " . "FROM webfinance_invoice_rows " . "WHERE id_facture=%d", $_POST['id_facture'], mysql_real_escape_string($_POST['line_new']), $_POST['prix_ht_new'], $_POST['qtt_new'], $_POST['id_facture']);
     $result = mysql_query($q) or wf_mysqldie();
     mysql_query("UPDATE webfinance_invoices SET date_generated=NULL WHERE id_facture=" . $_POST['id_facture']) or wf_mysqldie();
 }
 // Enregistrement des lignes existantes
 foreach ($_POST as $k => $v) {
     if (preg_match("/^line_([0-9]+)\$/", $k, $matches)) {
         $q = sprintf("UPDATE webfinance_invoice_rows SET description='%s', prix_ht='%s', qtt='%s' WHERE id_facture_ligne=%d", mysql_real_escape_string($_POST['line_' . $matches[1]]), str_replace(' ', '', $_POST['prix_ht_' . $matches[1]]), $_POST['qtt_' . $matches[1]], $matches[1]);
Example #4
0
?>
</td></tr>
    <tr><td>Code TVA Client</td><td><input style="width: 110px;" type="text" name="vat_number" value="<?php 
echo $facture->vat_number;
?>
" /></td></tr>
    <tr><td>Ref Contrat</td><td><input style="width: 200px;" type="text" name="ref_contrat" value="<?php 
echo $facture->ref_contrat;
?>
" /></td></tr>
    <tr><td>Paiement</td><td><input type="text" style="width: 200px;" name="type_paiement" value="<?php 
echo $facture->type_paiement;
?>
" /></td></tr>
    <tr><td>Accompte </td><td><input type="text" style="width: 50px; text-align: center;" name="accompte" value="<?php 
echo WFO::makeMonetaryFormat($facture->accompte);
?>
" /><?php 
echo $currency;
?>
 TTC</td></tr>
    <tr><td colspan="2">
    <textarea style="width: 300px; height: 40px" name="extra_top"><?php 
echo $facture->extra_top;
?>
</textarea>
    </table>
  </td>
<?php 
$query = "SELECT id_client, nom " . "FROM webfinance_clients ";
$result = mysql_query($query);