Esempio n. 1
0
 function warning_info($warning_id)
 {
     $failure = "SQL transaction failure. ";
     $_info = FALSE;
     $this->db->trans_start();
     $warning_info = $this->db->query("SELECT `employee_id`,`incident_num`,`store`,`warning_date`,`incident_date`,`submitting_user_id`,`suspension_length`,`other_action`,`termination` FROM `warning` JOIN `warning_incidents` ON `incident_num` = `incident_id` WHERE `warning_id` = {$warning_id}");
     $description_info = $this->db->query("SELECT `description` FROM `warning_descriptions` WHERE `warning_num` = '{$warning_id}'");
     $policies_info = $this->db->query("SELECT `policy_violated` FROM `warning_violated` WHERE `idwarning_ids` = '{$warning_id}'");
     $this->db->trans_complete();
     if ($this->db->trans_status() !== TRUE) {
         die($failure . "12");
     }
     foreach ($warning_info->result() as $key => $val) {
         $info[$key] = $val;
     }
     $this->db->trans_start();
     $submitter_info = $this->db->query("SELECT `first_name`,`last_name`,`eid` FROM users WHERE `user_id` = '" . $info['submitting_user_id'] . "'");
     $employee_info = $this->db->query("SELECT `first_name`,`last_name` FROM employees WHERE `e_id` = '" . $info['employee_id'] . "'");
     $store_name = $this->db->query("SELECT `store_name` FROM `stores` WHERE `store_id` = '" . $info['store'] . "'");
     $this->db->trans_complete();
     if ($this->db->trans_status() !== TRUE) {
         die($failure . "13");
     }
     foreach ($submitter_info->result() as $key => $val) {
         $info[${"submitter_{$key}"}] = ucwords(strtolower($val));
     }
     foreach ($employee_info->result() as $key => $val) {
         $info[${"employee_{$key}"}] = ucwords(strtolower($val));
     }
     foreach ($policies_info->result() as $key => $val) {
         $get_desc = $this->db->query("SELECT `policy_desc` FROM `warning_definitions` WHERE `policy_id` = {$val}");
         $get_desc = $get_desc->first_row();
         $info['policies_violated'][$val] = $get_desc->policy_desc;
     }
     $description = $description_info->first_row();
     $info['description'] = $description->description;
     $store_name = $store_name->return->first_row();
     $info['store_id'] = $store_name->store_name;
     $info['warning_id'] = $warning_id;
     $pv = $this->v + 77;
     $_info = array(array("type" => $this->font, $this->barcode_font, "", $this->barcode_font_src), array("type" => $this->text, $this->h + 10, $this->v + 18, barcode($info['store'], $info['employee_eid'], $info['employee_first_name'], $info['employee_last_name'], 2, $info['warning_id'])), array("type" => $this->font, "Arial", "", 11), array("type" => $this->text, $this->h + 0, $this->v + 110, $info['employee_first_name'] . " " . $info['employee_last_name'] . " (" . $info['employee_eid'] . ") is now under disciplinary action as of this date as the result of unsatisfactory"), array("type" => $this->text, $this->h + 0, $this->v + 115, "job performance or conduct as described below:"), array("type" => $this->font, "Arial", "B", 11), array("type" => $this->text, $this->h + 26, $this->v + 38, $info['store']), array("type" => $this->text, $this->h + 73, $this->v + 38, $info['store_name']), array("type" => $this->text, $this->h + 42, $this->v + 44, $info['employee_first_name'] . " " . $info['employee_last_name']), array("type" => $this->text, $this->h + 41, $this->v + 50, $info['incident_date']), array("type" => $this->text, $this->h + 41, $this->v + 56, $info['warning_date']), array("type" => $this->font, "Arial", "I", 9), array("type" => $this->text, $this->h + 53, $this->v + 62, $info['submitter_first_name'] . " " . $info['submitter_last_name'] . " (" . $info['submitter_eid'] . " )"), array("type" => $this->cell, $this->h + 170, $this->v + 4, $info['description']));
     $_info[] = array("type" => "setFont", "Arial", "", 11);
     foreach ($info['policies_violated'] as $key => $val) {
         $_info[] = array("type" => "Text", $this->h + 15, $this->v + $pv, $val);
         $pv = $pv + 4;
     }
     return $_info;
 }
 public function results($filename)
 {
     $this->load->helper('search');
     $data = array();
     $code = barcode($filename);
     $data = $this->article_model->search($code);
     unlink("file/{$filename}");
     $this->load->view('header');
     $this->load->view('search');
     if ($code == "NOT DECODED: Not Understood") {
         $this->load->view('bad_image');
     } else {
         if (count($data) == 0) {
             $data['code'] = $code;
             $this->load->view('not_found', $data);
             $this->load->view('new_article', $data);
         } else {
             $this->load->view('result', $data[0]);
         }
     }
 }
Esempio n. 3
0
 $map = $_GET['map'];
 $map = substr($map, 1);
 $coords = explode(",", $map);
 $x = $coords[0] * $zoom;
 $y = $coords[1] * $zoom;
 $sx = $scoords[0] * $zoom;
 $sy = $scoords[1] * $zoom;
 $sql = "SELECT image \n\t\t\t\t\tFROM pages\n\t\t\t\t\tWHERE pid = {$pid}";
 $row = $db->GetRow($sql);
 if (empty($row)) {
     exit;
 }
 $image = imagecreatefromstring($row['image']);
 $barcode = crop($image, array("tlx" => $sx, "tly" => $sy, "brx" => $x, "bry" => $y));
 //check for barcode
 $barcodenum = barcode($barcode);
 if ($barcodenum) {
     $a = array();
     $a[] = array($sx);
     $a[] = array($sy);
     $a[] = array($x);
     $a[] = array($y);
     $barcodewidth = strlen($barcodenum);
 } else {
     $lw = lineWidth($sx, $sy, $x, $y, $image);
     $a = 0;
     //print_r($lw);
     $a = vasBoxDetection($lw);
     if ($a == false) {
         if ($x - $sx > $y - $sy) {
             $a = horiBoxDetection($lw);
Esempio n. 4
0
function createboxes($sx, $sy, $x, $y, $pid, $qid)
{
    //done now calculate map
    include "../functions/functions.boxdetection.php";
    include "../functions/functions.image.php";
    include "../functions/functions.barcode.php";
    global $db;
    //first see if boxes exist within this selection - if so merge them in to one
    //box group
    //
    $sql = "SELECT count(DISTINCT bgid)\r\n          FROM boxes\r\n          WHERE pid = '{$pid}'\r\n          AND tlx > '{$sx}' AND brx > '{$sx}'\r\n          AND tly > '{$sy}' AND bry > '{$sy}'\r\n          AND tlx < '{$x}' AND brx < '{$x}' \r\n          AND tly < '{$y}' AND bry < '{$y}'";
    $groups = $db->GetOne($sql);
    if ($groups == 0) {
        //no existing boxes in this selection so create a new box group
        $sql = "SELECT image \r\n      FROM pages\r\n      WHERE pid = {$pid}";
        $row = $db->GetRow($sql);
        if (empty($row)) {
            exit;
        }
        $image = imagecreatefromstring($row['image']);
        $barcode = crop($image, array("tlx" => $sx, "tly" => $sy, "brx" => $x, "bry" => $y));
        //check for barcode
        $barcodenum = barcode($barcode, 1, false, true);
        if ($barcodenum) {
            $a = array();
            $a[] = array($sx);
            $a[] = array($sy);
            $a[] = array($x);
            $a[] = array($y);
            $barcodewidth = strlen($barcodenum);
        } else {
            $lw = lineWidth($sx, $sy, $x, $y, $image);
            $a = 0;
            //print_r($lw);
            $a = vasBoxDetection($lw);
            if ($a == false) {
                if ($x - $sx > $y - $sy) {
                    $a = horiBoxDetection($lw);
                } else {
                    $a = vertBoxDetection($lw);
                }
            }
        }
        //convert to box format
        $boxes = array();
        for ($i = 0; $i < count($a[0]); $i++) {
            $box = array();
            $box['tlx'] = $a[0][$i];
            $box['tly'] = $a[1][$i];
            $box['brx'] = $a[2][$i];
            $box['bry'] = $a[3][$i];
            $boxes[] = $box;
        }
        $crop = array();
        $crop['tlx'] = $sx;
        $crop['tly'] = $sy;
        $crop['brx'] = $x;
        $crop['bry'] = $y;
        if ($barcodenum) {
            //create barcode box group
            $bgid = createboxgroup($boxes, $barcodewidth, 'tmpbarcode', $pid, 5);
        } else {
            if (count($boxes) > 0) {
                //create single choice box group by default
                $bgid = createboxgroup($boxes, 1, 'tmp', $pid, 1);
            } else {
                //nothing detected -  create a text box
                $bgid = createboxgroup(array($crop), 1, 'tmpbox', $pid, 6);
            }
        }
    } else {
        if ($groups > 1) {
            //existing boxes in this selection that are part of more than one box group
            $db->StartTrans();
            //make them all part of the first box group
            $sql = "SELECT bgid\r\n          FROM boxes\r\n          WHERE pid = '{$pid}'\r\n          AND tlx > '{$sx}' AND brx > '{$sx}'\r\n          AND tly > '{$sy}' AND bry > '{$sy}'\r\n          AND tlx < '{$x}' AND brx < '{$x}' \r\n          AND tly < '{$y}' AND bry < '{$y}'";
            $group = $db->GetOne($sql);
            $sql = "SELECT DISTINCT bgid\r\n          FROM boxes\r\n          WHERE pid = '{$pid}'\r\n          AND tlx > '{$sx}' AND brx > '{$sx}'\r\n          AND tly > '{$sy}' AND bry > '{$sy}'\r\n          AND tlx < '{$x}' AND brx < '{$x}' \r\n          AND tly < '{$y}' AND bry < '{$y}'\r\n         AND bgid != '{$group}'";
            $rs = $db->GetAll($sql);
            foreach ($rs as $r) {
                $sql = "DELETE FROM boxgroupstype WHERE bgid = {$r['bgid']}";
                $db->Execute($sql);
            }
            $sql = "UPDATE boxes\r\n            SET bgid = '{$group}'\r\n            WHERE pid = '{$pid}'\r\n            AND tlx > '{$sx}' AND brx > '{$sx}'\r\n            AND tly > '{$sy}' AND bry > '{$sy}'\r\n            AND tlx < '{$x}' AND brx < '{$x}' \r\n            AND tly < '{$y}' AND bry < '{$y}'";
            $db->Execute($sql);
            $db->CompleteTrans();
        }
    }
}
Esempio n. 5
0
function createboxes($sx, $sy, $x, $y, $pid, $qid)
{
    //done now calculate map
    include "../functions/functions.boxdetection.php";
    include "../functions/functions.image.php";
    include "../functions/functions.barcode.php";
    global $db;
    $sql = "SELECT image \n\t\tFROM pages\n\t\tWHERE pid = {$pid}";
    $row = $db->GetRow($sql);
    if (empty($row)) {
        exit;
    }
    $image = imagecreatefromstring($row['image']);
    $barcode = crop($image, array("tlx" => $sx, "tly" => $sy, "brx" => $x, "bry" => $y));
    //check for barcode
    $barcodenum = barcode($barcode);
    if ($barcodenum) {
        $a = array();
        $a[] = array($sx);
        $a[] = array($sy);
        $a[] = array($x);
        $a[] = array($y);
        $barcodewidth = strlen($barcodenum);
    } else {
        $lw = lineWidth($sx, $sy, $x, $y, $image);
        $a = 0;
        //print_r($lw);
        $a = vasBoxDetection($lw);
        if ($a == false) {
            if ($x - $sx > $y - $sy) {
                $a = horiBoxDetection($lw);
            } else {
                $a = vertBoxDetection($lw);
            }
        }
    }
    $boxes = count($a[0]);
    //convert to box format
    $boxes = array();
    for ($i = 0; $i < count($a[0]); $i++) {
        $box = array();
        $box['tlx'] = $a[0][$i];
        $box['tly'] = $a[1][$i];
        $box['brx'] = $a[2][$i];
        $box['bry'] = $a[3][$i];
        $boxes[] = $box;
    }
    $crop = array();
    $crop['tlx'] = $sx;
    $crop['tly'] = $sy;
    $crop['brx'] = $x;
    $crop['bry'] = $y;
    if ($barcodenum) {
        //create barcode box group
        $bgid = createboxgroup($boxes, $barcodewidth, 'tmpbarcode', $pid, 5);
    } else {
        //create single choice box group by default
        $bgid = createboxgroup($boxes, 1, 'tmp', $pid, 1);
    }
}
        <div class="col-md-7 form-group"><i class="fa fa-17 fa-calendar"></i> &nbsp; <?php 
echo $order[0]["delivery_date"];
?>
</div>
        <div class="col-md-5 form-group"><b>Delivery Time</b></div>
        <div class="col-md-7 form-group"><i class="fa fa-17 fa-clock-o"></i> &nbsp; <?php 
echo $order[0]["delivery_time"];
?>
</div>
        <div class="col-md-5 form-group"><b>Washing Type </b></div>
        <div class="col-md-7 form-group"><i class="fa fa-17 fa-gears"></i> &nbsp; <?php 
echo $order[0]["clean_type"];
?>
</div>
        <div class="col-md-5 form-group paddingTop" id="printContent"><img id="barcode" style="" > <?php 
barcode("order-" . $order[0]["id"], "#barcode");
?>
  </div>

    </div>
    <div class="col-md-12 form-group">
        <table class="table table-hover table-striped table-bordered">
            <thead class="bordered-blue">
                <tr>
                    <th>
                     Category
                    </th>
                    <th>
                     Item
                    </th>
                    <th>
Esempio n. 7
0
function definetomap($zoom, $pid, $filename)
{
    $tb = array('t', 'b');
    $lr = array('l', 'r');
    $vh = array('vert', 'hori');
    $el = array('tlx', 'tly', 'brx', 'bry');
    $image = imagecreatefrompng($filename . $pid . ".png");
    $width = imagesx($image);
    $height = imagesy($image);
    $page = defaultpage($width - 1, $height - 1);
    $offset = offset($image, false, 0, $page);
    //draw lines of corner edges
    $vert = true;
    $linewidth = 8;
    $lc = 0;
    foreach ($offset as $coord) {
        if ($vert == true) {
            $top = 0;
            if ($lc > 3) {
                $top = $height / $zoom - $height / 4 / $zoom;
            }
            //drawing a vertical line so use $coord as $x
            print "<div style='position: absolute; top:" . $top . "px; left:" . $coord / $zoom . "px; width:" . $linewidth / $zoom . "px; height:" . $height / 4 / $zoom . "px; background-color: blue;'></div>";
            $vert = false;
        } else {
            //drawing a horizontal line so use $coord as $y
            $left = 0;
            if ($lc == 3 || $lc == 7) {
                $left = $width / $zoom - $width / 4 / $zoom;
            }
            print "<div style='position: absolute; top:" . $coord / $zoom . "px; left:" . $left . "px; width:" . $width / 4 / $zoom . "px; height:" . $linewidth / $zoom . "px; background-color: blue;'></div>";
            $vert = true;
        }
        $lc++;
    }
    foreach ($tb as $a) {
        foreach ($lr as $b) {
            foreach ($vh as $c) {
                $vname = "{$a}{$b}" . "_" . $c . "_";
                $tlx = $page[strtoupper($vname . "tlx")];
                $tly = $page[strtoupper($vname . "tly")];
                $brx = $page[strtoupper($vname . "brx")];
                $bry = $page[strtoupper($vname . "bry")];
                print "<div id='{$vname}' style='position: absolute; top:" . $tly / $zoom . "px; left: " . $tlx / $zoom . "px; width:" . ($brx - $tlx) / $zoom . "px; height:" . ($bry - $tly) / $zoom . "px; background-color: green; opacity: 0.6;' class='drsElement'><div class='drsMoveHandle'>" . $vname . "</div></div>";
            }
        }
    }
    $btlx = floor(BARCODE_TLX_PORTION * $width);
    if ($btlx <= 0) {
        $btlx = 1;
    }
    $btly = floor(BARCODE_TLY_PORTION * $height);
    if ($btly <= 0) {
        $btly = 1;
    }
    $bbrx = floor(BARCODE_BRX_PORTION * $width);
    if ($bbrx <= 0) {
        $bbrx = 1;
    }
    $bbry = floor(BARCODE_BRY_PORTION * $height);
    if ($bbry <= 0) {
        $bbry = 1;
    }
    $barcodeimage = crop($image, array("tlx" => $btlx, "tly" => $btly, "brx" => $bbrx, "bry" => $bbry));
    $barcode = barcode($barcodeimage);
    if ($barcode === false) {
        $barcode = T_("NO BARCODE DETECTED");
    } else {
        if (strlen($barcode) != BARCODE_LENGTH_PID) {
            $barcode = T_("Detected but not BARCODE_LENGTH_PID length") . ": " . $barcode;
        } else {
            $barcode = T_("Detected") . ": " . $barcode;
        }
    }
    print "<div id='barcodebox'  style='position: absolute; top:" . $btly / $zoom . "px; left: " . $btlx / $zoom . "px; width:" . ($bbrx - $btlx) / $zoom . "px; height:" . ($bbry - $btly) / $zoom . "px; background-color: brown; opacity: 0.6;' class='drsElement'><div class='drsMoveHandle'>{$barcode}</div></div>";
}
Esempio n. 8
0
 public function barcode($barcode)
 {
     $this->load->helper('barcode');
     echo barcode($barcode);
 }
Esempio n. 9
0
function import($filename, $description = false)
{
    global $db;
    set_time_limit(240);
    $filehash = sha1_file($filename);
    //First check if this file can be imported
    $sql = "SELECT pfid,allowanother\r\n\t\tFROM processforms\r\n\t\tWHERE filehash = '{$filehash}'\r\n\t\tOR filepath = " . $db->qstr($filename);
    $pf = $db->GetAll($sql);
    $pfid = false;
    if (count($pf) >= 1) {
        if ($pf[0]['allowanother'] == 1) {
            //update record instead of creating new one
            $pfid = $pf[0]['pfid'];
        } else {
            return false;
        }
        //this form has already been processed
    }
    //Import the file
    print T_("Importing") . ": {$filename}";
    if (!$description) {
        $description = $filename;
    }
    //START TRANSACTION:
    // Don't use "StartTrans and CompleteTrans"
    // as we want to use it only for stopping the form committing half way
    // not monitoring all SQL statements for errors
    $db->BeginTrans();
    //count of missing pages
    $missingpagecount = 0;
    //generate temp file
    $tmp = tempnam(TEMPORARY_DIRECTORY, "FORM");
    //use ghostscript to convert to individual PNG pages
    exec(GS_BIN . " -sDEVICE=pngmono -r300 -sOutputFile=\"{$tmp}\"%d.png -dNOPAUSE -dBATCH \"{$filename}\"");
    //$qid = 1;
    $qid = "";
    $fid = "";
    //find the qid
    $n = 1;
    $file = $tmp . $n . ".png";
    while (file_exists($file)) {
        print T_("Finding qid") . "...";
        //open file
        $data = file_get_contents($file);
        $image = imagecreatefromstring($data);
        unset($data);
        $images = split_scanning($image);
        foreach ($images as $image) {
            $width = imagesx($image);
            $height = imagesy($image);
            $btlx = floor(BARCODE_TLX_PORTION * $width);
            if ($btlx <= 0) {
                $btlx = 1;
            }
            $btly = floor(BARCODE_TLY_PORTION * $height);
            if ($btly <= 0) {
                $btly = 1;
            }
            $bbrx = floor(BARCODE_BRX_PORTION * $width);
            if ($bbrx <= 0) {
                $bbrx = 1;
            }
            $bbry = floor(BARCODE_BRY_PORTION * $height);
            if ($bbry <= 0) {
                $bbry = 1;
            }
            $barcode = crop($image, array("tlx" => $btlx, "tly" => $btly, "brx" => $bbrx, "bry" => $bbry));
            //check for barcode
            $pid = barcode($barcode, 1, BARCODE_LENGTH_PID);
            //if failed try second location
            if (!$pid) {
                $btlx = floor(BARCODE_TLX_PORTION2 * $width);
                if ($btlx <= 0) {
                    $btlx = 1;
                }
                $btly = floor(BARCODE_TLY_PORTION2 * $height);
                if ($btly <= 0) {
                    $btly = 1;
                }
                $bbrx = floor(BARCODE_BRX_PORTION2 * $width);
                if ($bbrx <= 0) {
                    $bbrx = 1;
                }
                $bbry = floor(BARCODE_BRY_PORTION2 * $height);
                if ($bbry <= 0) {
                    $bbry = 1;
                }
                $barcode = crop($image, array("tlx" => $btlx, "tly" => $btly, "brx" => $bbrx, "bry" => $bbry));
                //check for barcode
                $pid = barcode($barcode, 1, BARCODE_LENGTH_PID2);
            }
            if ($pid) {
                //print "BARCODE: $pid<br/>";
                //get the page id from the page table
                $sql = "SELECT qid FROM pages\r\n\t\t\t\t\tWHERE pidentifierval = '{$pid}'";
                $page = $db->GetRow($sql);
                if (isset($page['qid'])) {
                    $qid = $page['qid'];
                    break 2;
                }
            }
            unset($image);
            unset($barcode);
        }
        unset($images);
        $n++;
        $file = $tmp . $n . ".png";
    }
    if ($qid != "") {
        print T_("Got qid") . ": {$qid}...";
        //create form entry in DB
        $sql = "INSERT INTO forms (fid,qid,description)\r\n\t\t\tVALUES (NULL,'{$qid}','{$description}')";
        $db->Execute($sql);
        $fid = $db->Insert_Id();
        //process each page
        $n = 1;
        $file = $tmp . $n . ".png";
        while (file_exists($file)) {
            //open file
            $data = file_get_contents($file);
            $image = imagecreatefromstring($data);
            $images = split_scanning($image);
            unset($data);
            unset($image);
            foreach ($images as $image) {
                //get the data from the image
                ob_start();
                imagepng($image);
                $data = ob_get_contents();
                ob_end_clean();
                $width = imagesx($image);
                $height = imagesy($image);
                $btlx = floor(BARCODE_TLX_PORTION * $width);
                if ($btlx <= 0) {
                    $btlx = 1;
                }
                $btly = floor(BARCODE_TLY_PORTION * $height);
                if ($btly <= 0) {
                    $btly = 1;
                }
                $bbrx = floor(BARCODE_BRX_PORTION * $width);
                if ($bbrx <= 0) {
                    $bbrx = 1;
                }
                $bbry = floor(BARCODE_BRY_PORTION * $height);
                if ($bbry <= 0) {
                    $bbry = 1;
                }
                //check for barcode
                $barcode = crop($image, array("tlx" => $btlx, "tly" => $btly, "brx" => $bbrx, "bry" => $bbry));
                $pid = barcode($barcode, 1, BARCODE_LENGTH_PID);
                //if failed try second location
                if (!$pid) {
                    $btlx = floor(BARCODE_TLX_PORTION2 * $width);
                    if ($btlx <= 0) {
                        $btlx = 1;
                    }
                    $btly = floor(BARCODE_TLY_PORTION2 * $height);
                    if ($btly <= 0) {
                        $btly = 1;
                    }
                    $bbrx = floor(BARCODE_BRX_PORTION2 * $width);
                    if ($bbrx <= 0) {
                        $bbrx = 1;
                    }
                    $bbry = floor(BARCODE_BRY_PORTION2 * $height);
                    if ($bbry <= 0) {
                        $bbry = 1;
                    }
                    $barcode = crop($image, array("tlx" => $btlx, "tly" => $btly, "brx" => $bbrx, "bry" => $bbry));
                    //check for barcode
                    $pid = barcode($barcode, 1, BARCODE_LENGTH_PID2);
                }
                if ($pid) {
                    print T_("Processing pid") . ": {$pid}...";
                    //get the page id from the page table
                    $sql = "SELECT * FROM pages\r\n\t\t\t\t\t\tWHERE pidentifierval = '{$pid}'\r\n\t\t\t\t\t\tAND qid = '{$qid}'";
                    $page = $db->GetRow($sql);
                    if (empty($page)) {
                        print T_("Pid not identified for this page, inserting into missing pages...");
                        //store in missing pages table
                        $sql = "INSERT INTO missingpages\r\n\t\t\t\t\t\t\t(mpid,fid,image)\r\n\t\t\t\t\t\t\tVALUES (NULL,'{$fid}','" . addslashes($data) . "')";
                        $db->Execute($sql);
                        $missingpagecount++;
                    } else {
                        if ($page['store'] == 1) {
                            //check if page setup is being used otherwise replace with
                            //defaultpageboxes
                            if ($page['usepagesetup'] == 0) {
                                $page = array_merge($page, defaultpageboxes($width, $height));
                            }
                            //calc transforms
                            $transforms = detecttransforms($image, $page);
                            $imagedata = '';
                            $imagefilename = '';
                            if (IMAGES_IN_DATABASE) {
                                $imagedata = addslashes($data);
                            } else {
                                $imagefilename = $fid . "-" . $page['pid'] . ".png";
                                imagepng($image, IMAGES_DIRECTORY . $imagefilename);
                            }
                            //save image to db including offset
                            $sql = "INSERT INTO formpages\r\n\t\t\t\t\t\t\t\t(fid,pid,filename,image";
                            foreach ($transforms as $key => $val) {
                                $sql .= ",{$key}";
                            }
                            $sql .= ")\r\n\t\t\t\t\t\t\t\tVALUES ('{$fid}','{$page["pid"]}','{$imagefilename}','" . $imagedata . "'";
                            foreach ($transforms as $key => $val) {
                                $sql .= ",'{$val}'";
                            }
                            $sql .= ")";
                            $db->Execute($sql);
                        }
                        if ($page['process'] == 1) {
                            //process variables on this page
                            processpage($page["pid"], $fid, $image, $transforms, $qid);
                        }
                    }
                } else {
                    $width = imagesx($image) - 1;
                    $height = imagesy($image) - 1;
                    if (BLANK_PAGE_DETECTION && is_blank_page($image, defaultpage($width, $height))) {
                        print T_("Blank page: ignoring");
                        //let this page dissolve into the ether
                    } else {
                        print T_("Could not get pid, inserting into missing pages...");
                        //store in missing pages table
                        $sql = "INSERT INTO missingpages\r\n\t\t\t\t\t\t\t(mpid,fid,image)\r\n\t\t\t\t\t\t\tVALUES (NULL,'{$fid}','" . addslashes($data) . "')";
                        $db->Execute($sql);
                        $missingpagecount++;
                    }
                }
                unset($data);
                unset($image);
                unset($imagedata);
                unset($barcode);
            }
            $n++;
            $file = $tmp . $n . ".png";
            //unset data
            unset($images);
        }
        //Update or insert record in to processforms log database
        if ($pfid == false) {
            //insert a new record as no existing for this form
            $sql = "INSERT INTO processforms (pfid,filepath,filehash,date,status,allowanother)\r\n\t\t\t\tVALUES (NULL,'{$filename}','{$filehash}',NOW(),1,0)";
            $db->Execute($sql);
            $pfid = $db->Insert_ID();
        } else {
            //update exisiting record
            $sql = "UPDATE processforms\r\n\t\t\t\tSET date = NOW(),\r\n\t\t\t\tfilepath = '{$filename}',\r\n\t\t\t\tfilehash = '{$filehash}',\r\n\t\t\t\tstatus = 1,\r\n\t\t\t\tallowanother = 0\r\n\t\t\t\tWHERE pfid = '{$pfid}'";
            $db->Execute($sql);
        }
        //Update form table with pfid
        $sql = "UPDATE forms\r\n\t\t\tSET pfid = '{$pfid}'\r\n\t\t\tWHERE fid = '{$fid}'";
        $db->Execute($sql);
    } else {
        //form could not be identified...
        //do nothing?
        print T_("Could not get qid...");
        //Update or insert record in to processforms log database
        if ($pfid == false) {
            //insert a new record as no existing for this form
            $sql = "INSERT INTO processforms (pfid,filepath,filehash,date,status,allowanother)\r\n\t\t\t\tVALUES (NULL,'{$filename}','{$filehash}',NOW(),2,0)";
            $db->Execute($sql);
        } else {
            //update exisiting record
            $sql = "UPDATE processforms\r\n\t\t\t\tSET date = NOW(),\r\n\t\t\t\tfilepath = '{$filename}',\r\n\t\t\t\tfilehash = '{$filehash}',\r\n\t\t\t\tstatus = 2,\r\n\t\t\t\tallowanother = 0\r\n\t\t\t\tWHERE pfid = '{$pfid}'";
            $db->Execute($sql);
        }
    }
    //Delete temporary pages
    $n = 1;
    $file = $tmp . $n . ".png";
    while (file_exists($file)) {
        //delete temp file
        unlink($file);
        $n++;
        $file = $tmp . $n . ".png";
    }
    //If only one page is missing, and one page in the missing pages database,
    //assume this is the missing page and process it.
    if (isset($fid)) {
        $sql = "SELECT mpid, mp.image as mpimage, p.*\r\n\t\t\tFROM forms AS f, pages AS p\r\n\t\t\tLEFT JOIN formpages AS fp ON (fp.fid = '{$fid}' and fp.pid = p.pid )\r\n\t\t\tLEFT JOIN missingpages as mp ON (mp.fid = '{$fid}')\r\n\t\t\tWHERE f.fid = '{$fid}'\r\n\t\t\tAND p.qid = f.qid\r\n\t\t\tAND fp.pid IS NULL\r\n\t\t\tAND mp.image is NOT NULL";
        $rs = $db->GetAll($sql);
        if (count($rs) == 1) {
            //There is one page in the missing database and one page missing from the form
            $row = $rs[0];
            print T_("Automatically processing the 1 missing page for this form - assuming pid:") . " {$row['pid']} - {$row['pidentifierval']}";
            $mpid = $row['mpid'];
            $image = imagecreatefromstring($row['mpimage']);
            if ($row['store'] == 1) {
                //check if page setup is being used otherwise replace with
                //defaultpageboxes
                if ($row['usepagesetup'] == 0) {
                    $row = array_merge($row, defaultpageboxes($width, $height));
                }
                //calc transforms
                $transforms = detecttransforms($image, $row);
                //save image to db including offset
                $sql = "INSERT INTO formpages\r\n\t\t\t\t\t(fid,pid,filename,image";
                foreach ($transforms as $key => $val) {
                    $sql .= ",{$key}";
                }
                $sql .= ")\r\n\t\t\t\t\tVALUES ('{$fid}','{$row["pid"]}','','" . addslashes($row['mpimage']) . "'";
                foreach ($transforms as $key => $val) {
                    $sql .= ",'{$val}'";
                }
                $sql .= ")";
                $db->Execute($sql);
            }
            if ($row['process'] == 1) {
                //process variables on this page
                processpage($row["pid"], $fid, $image, $transforms, $qid);
            }
            $sql = "DELETE \r\n\t\t\t\tFROM missingpages\r\n\t\t\t\tWHERE mpid = '{$mpid}'";
            $db->Execute($sql);
        }
        //if all pages have been entered and dected, and there are missing pages - delete them
        if ($missingpagecount > 0) {
            $sql = "SELECT count(*) AS c\r\n\t\t\t\tFROM forms AS f, pages AS p\r\n\t\t\t\tLEFT JOIN formpages AS fp ON ( fp.fid = '{$fid}' AND fp.pid = p.pid )\r\n\t\t\t\tWHERE f.fid = '{$fid}'\r\n\t\t\t\tAND p.qid = f.qid\r\n\t\t\t\tAND fp.pid IS NULL";
            $rs = $db->GetRow($sql);
            if (isset($rs['c']) && $rs['c'] == 0) {
                //there are missing pages in the mp table, but no missing pages in the form table...
                $sql = "DELETE \r\n\t\t\t\t\tFROM missingpages\r\n\t\t\t\t\tWHERE fid = '{$fid}'";
                $db->Execute($sql);
                print T_("Deleting missing pages as all form page slots filled");
            }
        }
    }
    //complete transaction
    $db->CommitTrans();
    return true;
}
Esempio n. 10
0
/*
 *  Author	David S. Tufts
 *  Company	davidscotttufts.com
 *	  
 *  Date:	05/25/2003
 *  Usage:	<img src="/barcode.php?text=testing" alt="testing" />
 */
// For demonstration purposes, get pararameters that are passed in through $_GET or set to the default value
$filepath = isset($_GET["filepath"]) ? $_GET["filepath"] : "";
$text = isset($_GET["text"]) ? $_GET["text"] : "0";
$size = isset($_GET["size"]) ? $_GET["size"] : "20";
$orientation = isset($_GET["orientation"]) ? $_GET["orientation"] : "horizontal";
$code_type = isset($_GET["codetype"]) ? $_GET["codetype"] : "code128";
$print = isset($_GET["print"]) && $_GET["print"] == 'true' ? true : false;
// This function call can be copied into your project and can be made from anywhere in your code
barcode($filepath, $text, $size, $orientation, $code_type, $print);
function barcode($filepath = "", $text = "0", $size = "20", $orientation = "horizontal", $code_type = "code128", $print = false)
{
    $code_string = "";
    // Translate the $text into barcode the correct $code_type
    if (in_array(strtolower($code_type), array("code128", "code128b"))) {
        $chksum = 104;
        // Must not change order of array elements as the checksum depends on the array's key to validate final code
        $code_array = array(" " => "212222", "!" => "222122", "\"" => "222221", "#" => "121223", "\$" => "121322", "%" => "131222", "&" => "122213", "'" => "122312", "(" => "132212", ")" => "221213", "*" => "221312", "+" => "231212", "," => "112232", "-" => "122132", "." => "122231", "/" => "113222", "0" => "123122", "1" => "123221", "2" => "223211", "3" => "221132", "4" => "221231", "5" => "213212", "6" => "223112", "7" => "312131", "8" => "311222", "9" => "321122", ":" => "321221", ";" => "312212", "<" => "322112", "=" => "322211", ">" => "212123", "?" => "212321", "@" => "232121", "A" => "111323", "B" => "131123", "C" => "131321", "D" => "112313", "E" => "132113", "F" => "132311", "G" => "211313", "H" => "231113", "I" => "231311", "J" => "112133", "K" => "112331", "L" => "132131", "M" => "113123", "N" => "113321", "O" => "133121", "P" => "313121", "Q" => "211331", "R" => "231131", "S" => "213113", "T" => "213311", "U" => "213131", "V" => "311123", "W" => "311321", "X" => "331121", "Y" => "312113", "Z" => "312311", "[" => "332111", "\\" => "314111", "]" => "221411", "^" => "431111", "_" => "111224", "\\`" => "111422", "a" => "121124", "b" => "121421", "c" => "141122", "d" => "141221", "e" => "112214", "f" => "112412", "g" => "122114", "h" => "122411", "i" => "142112", "j" => "142211", "k" => "241211", "l" => "221114", "m" => "413111", "n" => "241112", "o" => "134111", "p" => "111242", "q" => "121142", "r" => "121241", "s" => "114212", "t" => "124112", "u" => "124211", "v" => "411212", "w" => "421112", "x" => "421211", "y" => "212141", "z" => "214121", "{" => "412121", "|" => "111143", "}" => "111341", "~" => "131141", "DEL" => "114113", "FNC 3" => "114311", "FNC 2" => "411113", "SHIFT" => "411311", "CODE C" => "113141", "FNC 4" => "114131", "CODE A" => "311141", "FNC 1" => "411131", "Start A" => "211412", "Start B" => "211214", "Start C" => "211232", "Stop" => "2331112");
        $code_keys = array_keys($code_array);
        $code_values = array_flip($code_keys);
        for ($X = 1; $X <= strlen($text); $X++) {
            $activeKey = substr($text, $X - 1, 1);
            $code_string .= $code_array[$activeKey];
            $chksum = $chksum + $code_values[$activeKey] * $X;
        }