if (isset($_GET["start_at"]) && isset($_GET["finish_at"]) && $_GET["start_at"] != "" && $_GET["finish_at"] != "") { $start_at = strtotime($_GET["start_at"]); $finish_at = strtotime($_GET["finish_at"]); ?> <div class="box box-primary"> <div id="graph" class="animate" data-animate="fadeInUp" ></div> </div> <script> <?php echo "var c=0;"; echo "var dates=Array();"; echo "var data=Array();"; echo "var total=Array();"; for ($i = $start_at; $i <= $finish_at; $i += 60 * 60 * 24) { $operations = BuyData::getAllByDate(date("Y-m-d", $i)); $total = 0; foreach ($operations as $buy) { $opxs = BuyProductData::getAllByBuyId($buy->id); foreach ($opxs as $op) { $product = $op->getProduct(); $total += $op->q * $product->price; } } // echo $operations[0]->t; // $sl = $operations[0]->t!=null?$operations[0]->t:0; // $sp = $spends[0]->t!=null?$spends[0]->t:0; echo "dates[c]=\"" . date("Y-m-d", $i) . "\";"; echo "data[c]=" . $total . ";"; echo "total[c]={x: dates[c],y: data[c]};"; echo "c++;";