Ejemplo n.º 1
0
 /**
  * Fill a flow struct
  *
  * @param array      &$array   The flow struct to fill
  * @param CProduct[] $products Products
  * @param int        $n        N*$unit
  * @param string     $start    Start date
  * @param string     $unit     Time unit
  * @param CService[] $services Services
  *
  * @return void
  */
 private static function fillFlow(&$array, $products, $n, $start, $unit, $services)
 {
     foreach ($services as $_key => $_service) {
         $array["out"]["total"][$_key] = array(0, 0);
     }
     $d =& $array["out"];
     // Y init
     for ($i = 0; $i < 12; $i++) {
         $from = CMbDT::date("+{$i} {$unit}", $start);
         $d[$from] = array();
     }
     $d["total"] = array("total" => array(0, 0));
     for ($i = 0; $i < $n; $i++) {
         $from = CMbDT::date("+{$i} {$unit}", $start);
         $to = CMbDT::date("+1 {$unit}", $from);
         // X init
         foreach ($services as $_key => $_service) {
             $d[$from][$_key] = array(0, 0);
             if (!isset($d["total"][$_key])) {
                 $d["total"][$_key] = array(0, 0);
             }
         }
         $d[$from]["total"] = array(0, 0);
         $all_counts = self::getConsumptionMultipleProducts($products, $from, $to, $services, false);
         $by_product = array();
         foreach ($all_counts as $_data) {
             $by_product[$_data["product_id"]][$_data["service_id"]] = $_data["sum"];
         }
         /** @var CProduct $_product */
         foreach ($products as $_product) {
             $counts = CValue::read($by_product, $_product->_id, array());
             $coeff = 1;
             $ref = reset($_product->loadRefsReferences(true));
             if ($ref) {
                 $coeff = $ref->price;
             }
             foreach ($services as $_key => $_service) {
                 $_count = CValue::read($counts, $_key, 0);
                 $_price = $_count * $coeff;
                 $d[$from][$_key][0] += $_count;
                 $d[$from][$_key][1] += $_price;
                 $d[$from]["total"][0] += $_count;
                 $d[$from]["total"][1] += $_price;
                 @($d["total"][$_key][0] += $_count);
                 @($d["total"][$_key][1] += $_price);
                 @($d["total"]["total"][0] += $_count);
                 @($d["total"]["total"][1] += $_price);
             }
         }
     }
     $d = array_map_recursive(array("CProduct", "round2"), $d);
     // Put the total at the end
     $total = $d["total"];
     unset($d["total"]);
     $d["total"] = $total;
     $total = $d["total"]["total"];
     unset($d["total"]["total"]);
     $d["total"]["total"] = $total;
     $d = CMbArray::transpose($d);
 }
Ejemplo n.º 2
0
foreach ($aides_antecedent as $type => $_aides_by_type) {
    foreach ($_aides_by_type as $appareil => $_aides_by_appareil) {
        $i = 0;
        $temp_count = 0;
        $count = round(count($_aides_by_appareil) / 4);
        $aides = array();
        foreach ($_aides_by_appareil as $_aide) {
            $aides[$i][] = $_aide;
            $temp_count++;
            if ($temp_count > $count) {
                $temp_count = 0;
                $i++;
            }
        }
        $antecedent->_count_rques_aides_appareil[$type][$appareil] = count($_aides_by_appareil);
        $aides = CMbArray::transpose($aides);
        $aides_antecedent[$type][$appareil] = $aides;
    }
}
$applied_traitements = array();
foreach ($dossier_medical->_ref_traitements as $a) {
    $applied_traitements[$a->traitement] = true;
}
$traitement = new CTraitement();
$traitement->loadAides($user->_id);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("aides_antecedent", $aides_antecedent);
$smarty->assign("antecedent", $antecedent);
$smarty->assign("traitement", $traitement);
$smarty->assign("applied_antecedents", $applied_antecedents);
Ejemplo n.º 3
0
 public function testTranspose()
 {
     $array = array(array("val1", "val2", "val3"), array("val1", "val2", "val3"));
     $res = array(array("val1", "val1"), array("val2", "val2"), array("val3", "val3"));
     $this->assertEquals($res, $this->stub->transpose($array));
 }