/** * Trace a query applying syntax coloring * * @param string $query Query to execute * @param array $values Values to prepare * * @return void */ static function traceQuery($query, $values = array()) { self::$last_query = $query; self::$last_values = $values; // Verbose if (!self::$verbose) { return; } // Inject values into query foreach ($values as $_value) { $_value = str_replace("'", "\\'", $_value); $query = preg_replace("/\\?/", "'{$_value}'", $query, 1); } echo utf8_decode(CMbString::highlightCode("sql", $query, false, "white-space: pre-wrap;")); }
$type = CValue::get("type"); $offset = CValue::get("offset"); $step = CValue::get("step"); CRecordSante400::$verbose = CValue::get("verbose"); if (!$type) { CAppUI::stepAjax("CMouvement400-error-no_type", UI_MSG_ERROR); } CAppUI::stepAjax("CMouvement400-alert-import", UI_MSG_ALERT, $type, $offset, $step); $mouv = CMouvFactory::create($type); if (!$mouv->origin || !$mouv->origin_key_field) { CAppUI::stepAjax("CMouvement400-error-trigger_no_origin", UI_MSG_WARNING, $mouv->class); return; } $query = "SELECT * FROM {$mouv->base}.{$mouv->origin} \r\n WHERE {$mouv->origin_key_field} >= ?\r\n AND {$mouv->origin_key_field} < ?"; $values = array($offset, $offset + $step); $mouvs = CRecordSante400::loadMultiple($query, $values, $step, $mouv->class); $totals = array("success" => 0, "failure" => 0); $failures = array(); foreach ($mouvs as $_mouv) { $_mouv->value_prefix = $_mouv->origin_prefix; $origin_key = $_mouv->data[$mouv->origin_key_field]; // Initialize trigger field $data = array(); $data[$_mouv->trigger_key_field] = null; $data[$_mouv->type_field] = null; $data[$_mouv->when_field] = null; // Rebuild triggers fields foreach ($_mouv->data as $_field => $_value) { $data[$_mouv->old_prefix . $_field] = null; $data[$_mouv->new_prefix . $_field] = $_value; }
/** * Load latest with former marks * * @param int $max Max rows * * @return array */ function loadListWithFormerMark($max) { $query = "SELECT * FROM {$this->base}.{$this->table}\r\n WHERE {$this->mark_field} NOT IN ('', 'OKOKOKOK')"; $query .= $this->getFilterClause(); $query .= "\n ORDER BY {$this->trigger_key_field} DESC"; $mouvs = CRecordSante400::loadMultiple($query, array(), $max, get_class($this)); foreach ($mouvs as &$mouv) { $mouv->initialize(); } return $mouvs; }
<?php /** $Id: synchro_sante400.php 28037 2015-04-21 15:47:45Z mytto $ */ /** * @package Mediboard * @subpackage sante400 * @version $Revision: 28037 $ * @author SARL OpenXtrem * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html */ CCanDo::checkEdit(); CApp::setTimeLimit(90); CRecordSante400::$verbose = CValue::get("verbose"); $types = CMouvFactory::getTypes(); if (!count($types)) { CAppUI::stepMessage(UI_MSG_WARNING, "CMouvFactory-warning-noclasses"); return; } $marked = CValue::getOrSession("marked", "1"); $max = CValue::get("max", CAppUI::conf("sante400 nb_rows")); // Load mouvements $class = CValue::get("class"); $type = CValue::getOrSession("type"); $mouvs = array(); $count = 0; $procs = 0; if (!in_array($type, $types)) { $type = null; } // Mouvement type (or class) provided if ($type || $class) {