Exemplo n.º 1
0
 function get_parts_group($start_date, $end_date)
 {
     $results = array();
     $prods = Production::find('all', array('conditions' => array(' is_urgent = ? AND DATE(`urgent_date`) >= ? AND DATE(`urgent_date`) <= ?', 1, $start_date, $end_date), 'order' => 'id desc'));
     foreach ($prods as $prod) {
         // 零件
         foreach ($prod->parts as $part) {
             $_part = array('num' => $part->num, 'name' => $part->name, 'urgent_date' => date('Y-m-d', strtotime($prod->urgent_date)), 'count' => $part->count, 'procs' => array());
             foreach ($part->processes as $proc) {
                 if ($proc->planned_completion_date && !$proc->is_done) {
                     $_part['procs'][] = array('priority' => $proc->priority, 'name' => $proc->name, 'production_date' => $proc->production_date ? date('Y-m-d', strtotime($proc->production_date)) : '', 'planned_completion_date' => date('Y-m-d', strtotime($proc->planned_completion_date)), 'completion_date' => $proc->completion_date ? date('Y-m-d', strtottime($proc->completion_date)) : '');
                 }
             }
             if (count($_part['procs'])) {
                 $results[] = $_part;
             }
         }
     }
     return $results;
 }
Exemplo n.º 2
0
 function get_parts_group_with_filter($num)
 {
     $results = array();
     $parts = Part::find('all', array('conditions' => array(" num LIKE '%{$num}%'"), 'order' => 'id desc'));
     //debug( $parts );
     //exit;
     // 零件
     foreach ($parts as $part) {
         $_part = array();
         // 生产指令
         if ($part->production->is_urgent) {
             $_part = array('num' => $part->num, 'name' => $part->name, 'urgent_date' => date('Y-m-d', strtotime($part->production->urgent_date)), 'count' => $part->count, 'procs' => array());
             foreach ($part->processes as $proc) {
                 if ($proc->planned_completion_date && !$proc->is_done) {
                     $_part['procs'][] = array('priority' => $proc->priority, 'name' => $proc->name, 'production_date' => $proc->production_date ? date('Y-m-d', strtotime($proc->production_date)) : '', 'planned_completion_date' => date('Y-m-d', strtotime($proc->planned_completion_date)), 'completion_date' => $proc->completion_date ? date('Y-m-d', strtottime($proc->completion_date)) : '');
                 }
             }
         }
         if (!empty($_part) && count($_part['procs'])) {
             $results[] = $_part;
         }
     }
     return $results;
 }
} else {
    /**
     * Clears all open buffers so we can return a plain response for the Javascript.
     */
    ob_clear_open_buffers();
    if (isset($_GET["event_start"]) && (int) $_GET["event_start"]) {
        $event_start = $_GET["event_start"];
        $date_string = date("Y-m-d", $event_start);
    } elseif (isset($_POST["event_start"]) && (int) $_POST["event_start"]) {
        $event_start = $_POST["event_start"];
        $date_string = date("Y-m-d", $event_start);
    }
    if (isset($_GET["date_string"]) && (int) strtotime($_GET["date_string"])) {
        $date_string = $_GET["date_string"];
        $event_start = strtotime($date_string);
    } elseif (isset($_POST["date_string"]) && (int) strtottime($_POST["date_string"])) {
        $date_string = $_POST["date_string"];
        $event_start = strtotime($date_string);
    }
    if (isset($_GET["organisation_id"]) && (int) $_GET["organisation_id"]) {
        $organisation_id = $_GET["organisation_id"];
    } elseif (isset($_POST["organisation_id"]) && (int) $_POST["organisation_id"]) {
        $organisation_id = $_POST["organisation_id"];
    }
    if ($event_start && $date_string && $organisation_id) {
        $restricted_days = Models_RestrictedDays::fetchAll($organisation_id);
        foreach ($restricted_days as $restricted_day) {
            $restricted_string = date("Y-m-d", $restricted_day->getCalculatedDate(date("Y", $event_start), date("n", $event_start), $event_start));
            if ($restricted_string == $date_string) {
                echo "Found";
                break;