function recordConstruct($args)
 {
     if (count($args) > 1) {
         $name = $args[0];
         $owner_id = $args[1];
     }
     if (!empty($name)) {
         $this->name = $name;
         $this->register_ts = time();
         $this->register_date = db_date();
     }
     if (isset($owner_id) && $owner_id > 0) {
         $this->save();
         $owner = new DB_Channel_Access();
         $owner->setChanId($this->channel_id);
         $owner->setUserId($owner_id);
         $owner->setLevel(500);
         $this->addAccess($owner);
     }
 }
Пример #2
0
/**
 * Update a token
 * @param integer Token ID
 * @param string Token value
 * @param integer Token expiration in seconds
 */
function token_update($p_token_id, $p_value, $p_expiry = TOKEN_EXPIRY)
{
    token_ensure_exists($p_token_id);
    $c_token_id = db_prepare_int($p_token_id);
    $c_value = db_prepare_string($p_value);
    $c_expiry = db_timestamp(db_date(time() + $p_expiry));
    $t_tokens_table = config_get('mantis_tokens_table');
    $query = "UPDATE {$t_tokens_table} \n\t\t\t\t\tSET value='{$c_value}', expiry={$c_expiry}\n\t\t\t\t\tWHERE id={$c_token_id}";
    db_query($query);
    return true;
}
Пример #3
0
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
db_queryf("delete from stats_servers");
db_queryf("delete from stats_users");
db_queryf("delete from stats_channels");
db_queryf("delete from stats_channel_users");
foreach ($this->servers as $num => $server) {
    db_queryf("insert into stats_servers (server_name, `desc`, start_date, max_users, isService) " . "values ('%s', '%s', '%s', '%s', '%s')", $server->getName(), $server->getDesc(), db_date($server->getStartTs()), $server->getMaxUsers(), $server->isService());
}
foreach ($this->users as $numeric => $user) {
    $server = $this->getServer($user->getServerNumeric());
    db_queryf("insert into stats_users \n\t\t\t(nick, ident, host, name, server, modes, account, signon_date)\n\t\t\tvalues\n\t\t\t('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $user->getNick(), $user->getIdent(), $user->getHost(), $user->getName(), $server->getName(), $user->getModes(), $user->getAccountName(), db_date($user->getSignonTs()));
}
foreach ($this->channels as $chan_key => $chan) {
    db_queryf("insert into stats_channels (channel_name, topic, modes) values ('%s', '%s', '%s')", $chan->getName(), $chan->getTopic(), $chan->getModes());
    foreach ($chan->getUserList() as $numeric) {
        $user = $this->getUser($numeric);
        db_queryf("insert into stats_channel_users (channel_name, nick, isOp, isVoice) values \n\t\t\t\t('%s', '%s', '%s', '%s')", $chan->getName(), $user->getNick(), $chan->isOp($numeric), $chan->isVoice($numeric));
    }
}
Пример #4
0
<?php

include '../include.php';
url_query_require();
$d = db_grab('SELECT 
		d.title, 
		t.extension, 
		d.content 
	FROM docs d 
	JOIN docs_types t ON d.type_id = t.id
	WHERE d.id = ' . $_GET['id']);
db_query('INSERT INTO docs_views ( documentID, userID, viewedOn ) VALUES ( ' . $_GET['id'] . ', ' . user() . ', ' . db_date() . ' )');
file_download($d['content'], $d['title'], $d['extension']);
                    } else {
                        $t_metrics[3][$t_ptr] += $t_data[$t][$t_status];
                    }
                }
            }
        }
    } else {
        $i = 0;
        foreach ($t_view_status as $t_status => $t_label) {
            if (isset($t_data[$t][$t_status])) {
                $t_metrics[++$i][$t_ptr] = $t_data[$t][$t_status];
            } else {
                $t_metrics[++$i][$t_ptr] = 0;
            }
        }
    }
    if ($f_show_as_table) {
        echo '<tr class="row-' . ($t_ptr % 2 + 1) . '"><td>' . $t_ptr . ' (' . db_date($t_metrics[0][$t_ptr]) . ')' . '</td>';
        for ($i = 1; $i <= $t_label_count; $i++) {
            echo '<td>' . $t_metrics[$i][$t_ptr] . '</td>';
        }
        echo '</tr>';
    }
}
if ($f_show_as_table) {
    echo '</table>';
    html_body_end();
    html_end();
} else {
    graph_bydate($t_metrics, $t_labels, lang_get('by_category'), $f_width, $f_width * $t_ar);
}
Пример #6
0
     // scale the amount of premium accordingly
     // but need to round it down otherwise strtotime may fail
     $expires = strtotime(db_date($expires) . " +" . max(0, floor($address['months'] * ($balance['balance'] / $address['balance']))) . " months +" . max(0, floor($address['years'] * ($balance['balance'] / $address['balance']))) . " years");
     crypto_log("New premium expiry date: " . db_date($expires));
     // apply premium data to user account
     $q = db()->prepare("UPDATE user_properties SET updated_at=NOW(),is_premium=1, premium_expires=?, is_reminder_sent=0 WHERE id=? LIMIT 1");
     $q->execute(array(db_date($expires), $address['user_id']));
     // update outstanding premium as paid
     $q = db()->prepare("UPDATE outstanding_premiums SET is_paid=1,paid_at=NOW(),paid_balance=? WHERE id=?");
     $q->execute(array($balance['balance'], $address['id']));
     // update jobs to premium priority
     $q = db()->prepare("UPDATE jobs SET priority=? WHERE user_id=? AND is_executed=0 AND priority > ?");
     $q->execute(array(get_site_config('premium_job_priority'), $address['user_id'], get_site_config('premium_job_priority')));
     crypto_log("Updated old jobs to new priority");
     if ($user['email']) {
         send_user_email($user, "purchase_partial", array("name" => $user['name'] ? $user['name'] : $user['email'], "amount" => number_format_autoprecision($address['balance']), "received" => number_format_autoprecision($balance['balance']), "currency" => get_currency_abbr($address['currency']), "currency_name" => get_currency_name($address['currency']), "expires" => db_date($expires), "address" => $address['address'], "explorer" => get_explorer_address($address['currency'], $address['address']), "url" => absolute_url(url_for("user#user_premium")), "profile_url" => absolute_url(url_for("user#user_premium")), "reminder" => $reminder, "cancelled" => $cancelled));
         crypto_log("Sent e-mail to " . htmlspecialchars($user['email']) . ".");
     }
 } else {
     // the user hasn't paid a thing
     // mark it as unpaid
     $q = db()->prepare("UPDATE outstanding_premiums SET is_unpaid=1,cancelled_at=NOW() WHERE id=?");
     $q->execute(array($address['id']));
     // release the premium address
     $q = db()->prepare("UPDATE premium_addresses SET is_used=0,used_at=NULL WHERE id=?");
     $q->execute(array($address['premium_address_id']));
     if ($user['email']) {
         send_user_email($user, "purchase_cancelled", array("name" => $user['name'] ? $user['name'] : $user['email'], "amount" => number_format_autoprecision($address['balance']), "received" => number_format_autoprecision($balance['balance']), "currency" => get_currency_abbr($address['currency']), "currency_name" => get_currency_name($address['currency']), "address" => $address['address'], "explorer" => get_explorer_address($address['currency'], $address['address']), "url" => absolute_url(url_for("user#user_premium")), "reminder" => $reminder, "cancelled" => $cancelled));
         crypto_log("Sent e-mail to " . htmlspecialchars($user['email']) . ".");
     }
 }
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
$oper_count = 0;
$service_count = 0;
$service_server_count = 0;
foreach ($this->users as $num => $user) {
    if ($user->isService()) {
        $service_count++;
    }
    if ($user->isOper()) {
        $oper_count++;
    }
}
foreach ($this->servers as $num => $serv) {
    if ($serv->isService()) {
        $service_server_count++;
    }
}
db_queryf("insert into stats_history \n\t\t(date, servers, users, channels, accounts, opers, services, service_servers) \n\t\tvalues ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", db_date(time()), count($this->servers), count($this->users), count($this->channels), count($this->accounts), $oper_count, $service_count, $service_server_count);
Пример #8
0
/*
 * ircPlanet Services for ircu
 * Copyright (c) 2005 Brian Cline.
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. Neither the name of ircPlanet nor the names of its contributors may be
 *    used to endorse or promote products derived from this software without 
 *    specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
db_queryf("insert into stats_servers (server_name, `desc`, start_date, max_users, isService) " . "values ('%s', '%s', '%s', '%s', '%s')", $server->getName(), $server->getDesc(), db_date($server->getStartTs()), $server->getMaxUsers(), $server->isService());
                      <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr> 
                          <td class="tabfonte" colspan="4"> <hr> </td>
                        </tr>
                        <tr> 
                          <td class="tabfonte" width="18%"> Data Inicio 
                            Atividades:</td>
                          <td class="tabfonte" width="21%"> &nbsp; 
                            <?php 
echo db_date($q02_dtinic, '/');
?>
                            </td>
                          <td class="tabfonte" width="14%"> Data Baixa:</td>
                          <td class="tabfonte" width="47%">&nbsp; 
                            <?php 
echo db_date($q02_dtbaix, '/');
?>
                            </td>
                        </tr>
                        <tr> 
                          <td class="tabfonte" width="18%">&nbsp;</td>
                          <td class="tabfonte" width="21%">&nbsp;</td>
                          <td class="tabfonte" width="14%">&nbsp;</td>
                          <td class="tabfonte" width="47%">&nbsp;</td>
                        </tr>
                        <tr> 
                          <td class="tabfonte" width="18%"> Inscri&ccedil;&atilde;o 
                            Estadual:</td>
                          <td class="tabfonte" width="21%"> &nbsp; 
                            <?php 
echo $z01_incest;
               </tr>
               <tr> 
                 <td width="24%"><strong><font size="2" color="black" face="Arial, Helvetica, sans-serif">Valor 
                   &agrave; Recolher:</font></strong></td>
                 <td width="76%"><font size="2" color="black" face="Arial, Helvetica, sans-serif">&nbsp; 
                   <?php 
 echo $valorpagamento;
 ?>
                   </font></td>
               </tr>
               <tr> 
                 <td width="24%"><strong><font size="2" color="black" face="Arial, Helvetica, sans-serif">Data 
                   vencimento:</font></strong></td>
                 <td width="76%"><font size="2" color="black" face="Arial, Helvetica, sans-serif">&nbsp; 
                   <?php 
 echo db_date($datavencimento, '/');
 ?>
                   </font></td>
               </tr>
               <tr> 
                 <td width="24%" valign="top"><strong><font size="2" color="black" face="Arial, Helvetica, sans-serif">Observa&ccedil;&otilde;es:</font></strong></td>
                 <td width="76%"> <font size="2" color="black" face="Arial, Helvetica, sans-serif">&nbsp; 
                   <?php 
 echo substr($obsliber, 0, 40);
 ?>
                   <br>
                   &nbsp; 
                   <?php 
 echo substr($obsliber, 40, 40);
 ?>
                   <br>
Пример #11
0
// sort and display the results
sort($t_category);
if ($f_show_as_table) {
    html_begin();
    html_head_begin();
    html_css();
    html_content_type();
    html_head_end();
    html_body_begin();
    echo '<table class="width100"><tr><td></td>';
    foreach ($t_category as $t_cat) {
        echo '<th>' . $t_cat . '</th>';
    }
    echo '</tr>';
    for ($t_ptr = 0; $t_ptr < $t_bin_count; $t_ptr++) {
        echo '<tr class="row-' . ($t_ptr % 2 + 1) . '"><td>' . $t_ptr . ' (' . db_date($t_marker[$t_ptr]) . ')' . '</td>';
        foreach ($t_category as $t_cat) {
            echo '<td>' . (isset($t_data[$t_ptr][$t_cat]) ? $t_data[$t_ptr][$t_cat] : 0) . '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
    html_body_end();
    html_end();
} else {
    // reverse the array and reorder the data, if necessary
    $t_metrics = array();
    for ($t_ptr = 0; $t_ptr < $t_bin_count; $t_ptr++) {
        $t = $t_bin_count - $t_ptr - 1;
        $t_metrics[0][$t_ptr] = $t_marker[$t];
        $i = 0;
Пример #12
0
    function weekly()
    {
        $year_week = cm_get('year_week', 'string') or $year_week = date('Y_W');
        list($year, $week) = split('_', $year_week);
        $year = (int) $year;
        $week = (int) $week;
        if (isset($_GET['go'])) {
            $week += $_GET['go'] == 'prev' ? -1 : 1;
            if ($week == 0) {
                $year--;
                $week = 53;
            } elseif ($week == 54) {
                $year++;
                $week = 1;
            }
        }
        lg($week . ' week of ' . $year . ' year');
        $first_jan = mktime(0, 0, 0, 1, 1, $year);
        $weekday_first_jan = (int) strftime('%w', $first_jan);
        $delta = 4 - $weekday_first_jan;
        if ($delta < 0) {
            $delta = $delta + 7;
        }
        $first_week_start = $first_jan + ($delta - 3) * 86400;
        $nth_week_start = $first_week_start + 86400 * 7 * ($week - 1);
        $nth_week_end = $nth_week_start + 86400 * 7 - 1;
        $date_start = db_date($nth_week_start);
        $date_end = db_date($nth_week_end);
        $sql_breakdown = '
			SELECT SUM(outlay.value) AS sum, c.name
			FROM
				outlay INNER JOIN
				outlay_category c ON c.id = outlay.outlay_category_id
			WHERE
				outlay.created_at BETWEEN "' . $date_start . '" AND "' . $date_end . '"
			GROUP BY
				c.name
		';
        $this->tpl->add('breakdown', db_fetch_all($sql_breakdown));
        $sql = '
			SELECT
				outlay.*,
				c.name,
				user.name as author_name,
				DAY(outlay.created_at) as weekday
			FROM
				outlay INNER JOIN
				outlay_category c ON c.id = outlay.outlay_category_id LEFT JOIN
				user ON user.id = outlay.user_id
			WHERE
				outlay.created_at BETWEEN "' . $date_start . '" AND "' . $date_end . '"
			ORDER BY
				MONTH(outlay.created_at),
				weekday ASC,
				c.name ASC,
				outlay.created_at
		';
        $outlay_records = db_fetch_all($sql);
        $weekdata = array();
        $prev_weekday = -1;
        $day->total = 0;
        $day->last_record_time = 0;
        $day->items = array();
        $cat->total = 0;
        $cat->items = array();
        $prev_cat = '';
        foreach ($outlay_records as $outlay) {
            // add old category to day, if new cat or new day
            if ($prev_cat && $outlay->name !== $prev_cat || $prev_weekday !== -1 && $prev_weekday !== $outlay->weekday) {
                $day->total += $cat->total;
                $day->items[] = $cat;
                $last_record_time = $cat->items[count($cat->items) - 1]->created_at;
                if ($day->last_record_time < $last_record_time) {
                    $day->last_record_time = $last_record_time;
                }
                $cat = new stdClass();
                $cat->total = 0;
                $cat->items = array();
            }
            // add old day to week, if new day
            if ($prev_weekday !== -1 && $prev_weekday !== $outlay->weekday) {
                $last_cat = $day->items[count($day->items) - 1];
                $last_record_time = $last_cat->items[count($last_cat->items) - 1]->created_at;
                if ($day->last_record_time < $last_record_time) {
                    $day->last_record_time = $last_record_time;
                }
                $weekdata[] = $day;
                $day = new stdClass();
                $day->total = 0;
                $day->items = array();
            }
            $cat->total += $outlay->value;
            $cat->items[] = $outlay;
            $prev_weekday = $outlay->weekday;
            $prev_cat = $outlay->name;
        }
        if ($prev_cat) {
            $day->total += $cat->total;
            $day->items[] = $cat;
            $last_record_time = $cat->items[count($cat->items) - 1]->created_at;
            if ($day->last_record_time < $last_record_time) {
                $day->last_record_time = $last_record_time;
            }
        }
        if ($prev_weekday !== -1) {
            $weekdata[] = $day;
        }
        $this->tpl->add('index', $outlay);
        $this->tpl->add('weekdata', $weekdata);
        $this->tpl->add('year', $year);
        //die(date('Y_W', $first_week_start));
        $this->tpl->add('week', $week);
        $this->tpl->view('outlay.index');
    }
Пример #13
0
}
if ($this->getChannelRegCount($user->getAccountId()) >= MAX_CHAN_REGS) {
    $bot->noticef($user, 'You cannot register more than %d channels.', MAX_CHAN_REGS);
    return false;
}
$reg = $this->getChannelReg($chan_name);
$chan = $this->getChannel($chan_name);
if ($reg) {
    $bot->noticef($user, 'Sorry, %s is already registered.', $reg->getName());
    return false;
}
if ($this->isBadchan($chan_name)) {
    $bot->noticef($user, 'Sorry, but you are not allowed to register %s.', $chan_name);
    return false;
}
if (!$chan || !$chan->isOp($user->getNumeric())) {
    $bot->noticef($user, 'You must be an op in %s in order to register it.', $chan_name);
    return false;
}
$create_ts = time();
if ($chan != NULL) {
    $create_ts = $chan->getTs();
}
$reg = new DB_Channel($chan_name, $user->getAccountId());
$reg->setPurpose($purpose);
$reg->setCreateTs($create_ts);
$reg->setRegisterDate(db_date());
$reg->save();
$reg = $this->addChannelReg($reg);
$bot->join($chan_name);
$this->mode($chan_name, '+Ro ' . $bot->getNumeric());
Пример #14
0
<?php

$events = db_query('SELECT
			e.id, 
			e.title' . langExt() . ' title, 
			e.start_date,
			t.color
		FROM cal_events e
		LEFT JOIN cal_events_types t ON e.type_id = t.id
		' . getChannelsWhere('cal_events', 'e', 'event_id') . ' AND e.start_date > ' . db_date() . '
		ORDER BY e.start_date ASC', 4);
if (db_found($events)) {
    while ($e = db_fetch($events)) {
        $return .= '
	<tr>
		<td width="80%"><a href="/' . $m['folder'] . '/event.php?id=' . $e['id'] . '" class="block" style="background-color:' . $e['color'] . ';">' . $e['title'] . '</a></td>
		<td width="20%" align="right">' . format_date($e['start_date'], "", "%b %d") . '</td>
	</tr>';
    }
} else {
    $return .= '<tr><td colspan="2" class="empty">' . getString('events_empty') . '</td></tr>';
}
            $CRITERIO .= " AND facturas.folio =" . $_GET['flio'];
        }
    }
    if (isset($_GET['folio2']) && $_GET['folio2'] != "") {
        $CRITERIO .= " AND facturas.folio <=" . $_GET['folio2'];
    }
    if (isset($_GET['serie']) && $_GET['serie'] != "") {
        $CRITERIO .= " AND facturas.serie='" . $_GET['serie'] . "'";
    }
    if (isset($_GET['diai']) && $_GET['diai'] != "") {
        $fechainicial = $_GET['aai'] . "-" . $_GET['mmi'] . "-" . $_GET['diai'];
        $CRITERIO .= " AND facturas.timestampemision >='" . $fechainicial . " 00:00:00'";
    }
    if (isset($_GET['diat']) && $_GET['diat'] != "") {
        $fechafinal = $_GET['aat'] . "-" . $_GET['mmt'] . "-" . $_GET['diat'];
        $CRITERIO .= " AND facturas.timestampemision <='" . db_date($_GET['fechafinal']) . " 23:59:59'";
    }
    if (isset($_GET['clnt']) && $_GET['clnt'] != "") {
        $CRITERIO .= " AND face_factura.razonsocial like '%" . $_GET['razonsocial'] . "%'";
    }
    if (isset($_GET['status']) && $_GET['status'] >= 0 && $_GET['status'] >= 0) {
        $CRITERIO .= " AND facturas.estatus = '" . $_GET['status'] . "'";
    }
    if (isset($_GET['ref3']) && !empty($_GET['ref3'])) {
        $CRITERIO .= " AND facturas.rfccliente like '%" . $_GET['ref3'] . "%'";
    }
}
$maxRows_facturas = 64000;
$pageNum_facturas = 0;
if (isset($_GET['pageNum_facturas'])) {
    $pageNum_facturas = $_GET['pageNum_facturas'];
Пример #16
0
 * ******************************************************* */
require_once "../../../lib/php/constantes.php";
require_once "{$RUTA_A}/Connections/fwk_db.php";
require_once "{$RUTA_A}/functions/utils.php";
if (isset($_POST['nfi']) && isset($_POST['nomprov']) && isset($_POST['tratamiento']) && isset($_POST['tipocompr']) && isset($_POST['pais']) && isset($_POST['ciudad']) && isset($_POST['direccion']) && isset($_POST['fax']) && isset($_POST['telefono']) && isset($_POST['fecha']) && isset($_POST['sexo']) && isset($_POST['dni']) && isset($_POST['usr'])) {
    require_once "{$RUTA_A}/functions/Proveedor.php";
    $nfi = $_POST['nfi'];
    $proveedor_name = utf8_decode($_POST['nomprov']);
    $tratamiento = $_POST['tratamiento'];
    $tipocomp = $_POST['tipocompr'];
    $pais = $_POST['pais'];
    $ciudad = $_POST['ciudad'];
    $direccion = $_POST['direccion'];
    $fax = $_POST['fax'];
    $telefono = $_POST['telefono'];
    $fecha = db_date($_POST['fecha']);
    $sexo = $_POST['sexo'];
    $dni = $_POST['dni'];
    $user = $_POST['usr'];
    $sociedad = "";
    $cnn = new conexion();
    $query = sprintf("SELECT cc_sociedad_id FROM cecos AS cc JOIN empleado AS e ON e.idcentrocosto=cc.cc_id JOIN usuario AS u ON e.idfwk_usuario=u.u_id WHERE u.u_id='%s'", $user);
    $rst = $cnn->consultar($query);
    while ($fila = mysql_fetch_assoc($rst)) {
        $sociedad = sprintf("%s", $fila['cc_sociedad_id']);
    }
    $sql = "SELECT pro_id FROM proveedores WHERE pro_nif = '{$nfi}' AND pro_sociedad = '{$sociedad}'";
    $res = $cnn->consultar($sql);
    $tot = mysql_num_rows($res);
    if (!$tot) {
        $proveedor = new Proveedor();
# --------------------------------------------------------
require_once 'core.php';
$t_core_path = config_get('core_path');
require_once $t_core_path . 'version_api.php';
form_security_validate('manage_proj_ver_copy');
auth_reauthenticate();
$f_project_id = gpc_get_int('project_id');
$f_other_project_id = gpc_get_int('other_project_id');
$f_copy_from = gpc_get_bool('copy_from');
$f_copy_to = gpc_get_bool('copy_to');
access_ensure_project_level(config_get('manage_project_threshold'), $f_project_id);
access_ensure_project_level(config_get('manage_project_threshold'), $f_other_project_id);
if ($f_copy_from) {
    $t_src_project_id = $f_other_project_id;
    $t_dst_project_id = $f_project_id;
} else {
    if ($f_copy_to) {
        $t_src_project_id = $f_project_id;
        $t_dst_project_id = $f_other_project_id;
    } else {
        trigger_error(ERROR_VERSION_NO_ACTION, ERROR);
    }
}
$t_rows = version_get_all_rows($t_src_project_id);
foreach ($t_rows as $t_row) {
    if (version_is_unique($t_row['version'], $t_dst_project_id)) {
        version_add($t_dst_project_id, $t_row['version'], $t_row['released'], $t_row['description'], db_date($t_row['date_order']));
    }
}
form_security_purge('manage_proj_ver_copy');
print_header_redirect('manage_proj_edit_page.php?project_id=' . $f_project_id);
?>
                  - 
                  <?php 
echo $z01_cep;
?>
                  - 
                  <?php 
echo $z01_uf;
?>
                </td>
              </tr>
              <tr> 
                <td class="tabfonte" width="19%" nowrap><strong>Data Inicio:</strong></td>
                <td class="tabfonte" width="81%"> 
                  <?php 
echo db_date($q02_dtinic, '/');
?>
&nbsp;

                </td>
              </tr>
              <?php 
for ($contador = 0; $contador < pg_numrows($result); $contador++) {
    db_fieldsmemory($result, $contador);
    ?>
              <?php 
}
?>
            </table></td>
        </tr>
      </table></td>
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
$last_update_ts = START_TIME;
if (!empty($timer_data)) {
    $last_update_ts = $timer_data[0];
}
$last_update = db_date($last_update_ts);
/**
 * Check for new and updated account records since this timer last ran
 */
$res = db_query('select account_id, name, update_date ' . 'from accounts ' . "where create_date >= '{$last_update}' or update_date >= '{$last_update}'", false);
while ($row = mysql_fetch_assoc($res)) {
    $account = $this->getAccount($row['name']);
    if (!$account) {
        /**
         * We've never seen this account before, so load it into memory and associate
         * it with any users who are using it.
         */
        $account = new DB_User($row['account_id']);
        $account_key = strtolower($account->getName());
        $this->accounts[$account_key] = $account;
        /**
Пример #20
0
function reporteSAT($fechainicial, $fechafinal, $idempresa)
{
    global $database_f4, $f4;
    $result = array();
    $CRITERIOG = "";
    $CRITERIOCAN = "";
    $CRITERIOGi = "";
    if (isset($fechainicial) && $fechainicial != "") {
        $CRITERIOG .= " AND ((timestampemision >='" . db_date($fechainicial, 0, 0) . " 00:00:00'";
        $CRITERIOGi .= " AND (fecha >='" . db_date($fechainicial, 0, 0) . " 00:00:00'";
        $CRITERIOCAN = " OR (fechacancelacion>='" . db_date($fechainicial, 0, 0) . " 00:00:00')";
    }
    if (isset($fechafinal) && $fechafinal != "") {
        $CRITERIOG .= " AND timestampemision <='" . db_date($fechafinal, 0, 0) . " 23:59:59')";
        $CRITERIOGi .= " AND fecha <='" . db_date($fechafinal, 0, 0) . " 23:59:59')";
        $CRITERIOCAN .= " AND fechacancelacion <='" . db_date($fechafinal, 0, 0) . " 23:59:59')";
    }
    mysql_select_db($database_f4, $f4);
    $sqlReporte = sprintf("select rfccliente,serie,folio,cast(folio as unsigned) as folioint, noaprob,anoaprob, timestampemision >= '%s 00:00:00' as mismomes,\r\n  date_format(timestampemision,'%%d/%%m/%%Y %%T') as timestampemision,monto,iva,facturas.estatus,fechacancelacion,\r\n  fechacancelacion>'%s' as postcancela, tipocfd, empresa.rfc\r\n   from facturas inner join empresa on (empresa.idempresa=facturas.idempresa) \r\n   where facturas.idempresa=%s " . $CRITERIOG . " " . $CRITERIOCAN . " ORDER BY serie ASC, folioint ASC", db_date($fechainicial, 0, 0), db_date($fechafinal, 0, 0), $idempresa);
    $facturasg = mysql_query($sqlReporte, $f4) or die(__LINE__ . mysql_error());
    $row_facturasg = mysql_fetch_assoc($facturasg);
    $totalRows_facturasg = mysql_num_rows($facturasg);
    $tmpToken = date('mY', strtotime(db_date($fechainicial, 0, 0)));
    $plain = "1" . $row_facturasg['rfc'] . $tmpToken . ".txt";
    //$fp=fopen($plain,"w+");
    $data = "";
    if ($totalRows_facturasg > 0) {
        do {
            //iva excento no lleva valor.
            $valorIVA = number_format(abs($row_facturasg['iva']), 2, ".", "");
            //tipo documento
            $TIPOCFD = "I";
            if ($row_facturasg['tipocfd'] == 3) {
                $TIPOCFD = "E";
            }
            if ($valorIVA < 0) {
                $valorIVA = "";
            }
            //fputs($fp,print_r($row_facturasg,true));
            if ($row_facturasg['postcancela'] == 1) {
                //la factura fue cancelada posterior a la fecha del reporte.
                $line = "|" . $row_facturasg['rfccliente'] . "|" . $row_facturasg['serie'] . "|" . intval($row_facturasg['folio']) . "|" . $row_facturasg['anoaprob'] . $row_facturasg['noaprob'] . "|" . $row_facturasg['timestampemision'] . "|" . number_format($row_facturasg['monto'], 2, ".", "") . "|" . $valorIVA . "|0|";
                $line .= $TIPOCFD . "||||\n";
                $data .= $line;
            } else {
                //registros cancelados en este mismo mes requieren de doble registro.
                if ($row_facturasg['estatus'] == 0) {
                    $fechacfd = strtotime($row_facturasg['timestampemision']);
                    $fechareporte = strtotime(db_date($fechainicial, 0, 0));
                    if ($row_facturasg['mismomes'] > 0) {
                        $line = "|" . $row_facturasg['rfccliente'] . "|" . $row_facturasg['serie'] . "|" . intval($row_facturasg['folio']) . "|" . $row_facturasg['anoaprob'] . $row_facturasg['noaprob'] . "|" . $row_facturasg['timestampemision'] . "|" . number_format($row_facturasg['monto'], 2, ".", "") . "|" . $valorIVA . "|1|";
                        $line .= $TIPOCFD . "||||\n";
                        $data .= $line;
                    }
                }
                $line = "|" . $row_facturasg['rfccliente'] . "|" . $row_facturasg['serie'] . "|" . intval($row_facturasg['folio']) . "|" . $row_facturasg['anoaprob'] . $row_facturasg['noaprob'] . "|" . $row_facturasg['timestampemision'] . "|" . number_format($row_facturasg['monto'], 2, ".", "") . "|" . $valorIVA . "|" . $row_facturasg['estatus'] . "|";
                $line .= $TIPOCFD . "||||\n";
                $data .= $line;
            }
        } while ($row_facturasg = mysql_fetch_assoc($facturasg));
        $download = true;
    }
    $result['archivo'] = $plain;
    $result['data'] = $data;
    return $result;
}
Пример #21
0
        $summary[$job_type]['count']++;
        if ($job['is_error']) {
            $summary[$job_type]['errors']++;
        }
        $summary[$job_type]['last'] = $job['executed_at'];
        $sample_size++;
    }
}
crypto_log(print_r($summary, true));
// update the database
// delete very old updates
$q = db()->prepare("DELETE FROM external_status WHERE DATE_ADD(created_at, INTERVAL 30 DAY) < NOW()");
$q->execute();
// other statuses are marked as old
$q = db()->prepare("UPDATE external_status SET is_recent=0");
$q->execute();
foreach ($summary as $key => $data) {
    $q = db()->prepare("INSERT INTO external_status SET is_recent=1, job_type=:key, job_count=:count, job_errors=:errors, job_first=:first, job_last=:last, sample_size=:sample_size");
    $q->execute(array("key" => $key, "count" => $data['count'], "errors" => $data['errors'], "first" => db_date($data['first']), "last" => db_date($data['last']), "sample_size" => $sample_size));
    // if there are no external_status_types for this job_type, insert one in
    $q = db()->prepare("SELECT * FROM external_status_types WHERE job_type=? LIMIT 1");
    $q->execute(array($key));
    if (!$q->fetch()) {
        crypto_log("No external_status_types found for job_type '" . htmlspecialchars($key) . "': inserting new mapping");
        $q = db()->prepare("INSERT INTO external_status_types SET job_type=?");
        $q->execute(array($key));
    }
    // TODO add is_daily_data flag, summarise data through cleanup, etc
}
crypto_log("Complete from " . number_format($sample_size) . " job samples into " . number_format(count($summary)) . " summary values.");
batch_footer();