<?php require_once "../Utilities/functions.php"; error_reporting(E_ALL); ini_set('display_errors', 1); session_start(); header("Access-Control-Allow-Origin: *"); $cmd = getValue("cmd"); if ($cmd == "addColor") { $response = addColor(); header('Content-type: application/json'); echo json_encode($response); } else { echo "\n <html>\n <body>\n <h1>API</h1>\n <ul>\n <li>\n <h2>command_name</h2>\n\n <h3>Parameters:</h3>\n <ul>\n <li>parameter</li>\n <li>parameter</li>\n <li>...</li>\n </ul>\n\n <h3>Returns:</h3>\n <p>desritpion of return value</p>\n\n <h3>Example:</h3>\n <p><a href='finename.php?query_string'>query_string</a></p>\n <pre>\n returned json\n </pre>\n </li>\n </ul>\n </body>\n </html>\n "; } function addColor() { $response = getSessionValue("listOfColors", []); $color = getValue("color"); $response[] = $color; setSessionValue("listOfColors", $response); return $response; }
echo "</tr>"; foreach ($recette->childNodes as $recetteComposant) { $couleur = $recetteComposant->getAttribute("position") % 2 == 0 ? "#F86F0A" : "#F9BB2F"; echo "<tr class='mh_tdtitre' align='center'>"; echo "<td class='mh_tdpage' width='200px'>"; echo "<h3 style='color:{$couleur};'>Position "; echo $recetteComposant->getAttribute("position") . " ("; echo $recetteComposant->getAttribute("position") % 2 == 0 ? "fixe" : "variable"; echo ")</h3>"; echo "</td>"; echo getComposantOption($recetteComposant); echo "</form></tr>"; } ?> <tr class='mh_tdtitre' align='center'> <td colspan='3'><h1 style='display:inline;'>Copie réalisable à : </h1><h1 id='ajustement' style='display:inline;'><?php echo addColor($recette->getAttribute("ratio") . "%"); ?> </h1></td> </tr> <tr class='mh_tdtitre' align='center'> <td colspan='3'> <textarea id="textarea" cols="150" rows="8"></textarea> </td> </tr> <tr class='mh_tdtitre' align='center'> <td class='mh_tdpage' colspan='3'><a href="index.php" style="text-decoration:none;"><img src="img/flecheg.jpg" alt="back"/></a></td> </tr> </table> <?php include '../foot.php';
function addColor($s) { // Découpe en BMP/BMM $s = explode("\\", $s); // Réappel la fonction si il y a des BMP/BMM if (count($s) == 2) { return addColor($s[0]) . "\\" . addColor($s[1]); } return preg_match("#-[0-9]+ min|\\+#", $s[0]) && !preg_match("#\\+[0-9]+ min#", $s[0]) ? spanColor("green", $s[0]) : spanColor("red", $s[0]); }
set_time_limit(0); header("Content-type: text/html; charset=utf-8"); $colorLibraryName = 'lulzbot.xml'; $colorXml = createColorLibrary($colorLibraryName); $productXml = simplexml_load_file('201601150831-lulzbot.xml'); $products = $productXml->product; $colorArray = array(); $index = 0; foreach ($products as $p) { $color = $p->color; if (strcasecmp($color, 'null') != 0 && !colorExistInArray($color, $colorArray)) { echo $color . '不存在<br/>'; $colorArray[] = $color; //添加到xml文件中 addColor($color, $colorXml); } else { echo $color . '存在<br/>'; } } $colorXml->asXml($colorLibraryName); /** *判断颜色数组中是否存在某种颜色 * */ function colorExistInArray($color, $colorArray) { $flag = false; foreach ($colorArray as $c) { if (strcasecmp($color, $c) == 0) { $flag = true;
public function getDecission (WorkflowSlotUser $user, $templateversion_id) { $result = array(); $a = 0; $processUsers = WorkflowProcessUserTable::instance()->getProcessUserByWorkflowSlotUserId($user->getId()); foreach($processUsers as $processUser) { $result[$a] = $processUser->toArray(); $result[$a]['received'] = format_date($result[$a]['inprogresssince'], 'g', $this->culture); $result[$a]['decission_id'] = $result[$a]['id']; $result[$a]['endreasion'] = ''; $result[$a]['useragent_id'] = $result[$a]['user_id']; $result[$a]['isuseragentof'] = $result[$a]['isuseragentof']; $usersettings = $this->user->getAttribute('userSettings'); $inProgress = createDayOutOfDateSince(date('Y-m-d', $result[$a]['inprogresssince'])); $inProgress = addColor($inProgress, $usersettings['markred'],$usersettings['markorange'],$usersettings['markyellow']); $result[$a]['inprogresssince'] = '<table><tr><td width="20">' . $inProgress . ' </td><td>' . $this->context->getI18N()->__('Days' ,null,'workflowmanagement') . '</td></tr></table>'; $result[$a]['decissioninwords'] = '<table><tr><td>'.AddStateIcon($result[$a]['decissionstate']).'</td><td>' . $this->context->getI18N()->__($result[$a]['decissionstate'],null,'workflowmanagement') . '</td></tr></table>'; if($result[$a]['decissionstate'] == 'STOPPEDBYADMIN') { $result[$a]['inprogresssince'] = '-'; } elseif($result[$a]['decissionstate'] == 'STOPPEDBYUSER') { $endReasion = WorkflowVersionTable::instance()->getWorkflowVersionById($templateversion_id); $result[$a]['endreasion'] = $endReasion[0]->getEndreason(); } $a++; } return $result; }
public function buildData(Doctrine_Collection $data, $counter) { $result = array(); $a = 0; $counter++; $authSettings = new CreateWorkflowAuthorizationRights(); $authSettings->setDefaultRole(); $authSettings->setUserRole($this->userId); $userSettings = $this->user->getAttribute('userSettings'); foreach($data as $item) { $sender = UserLoginTable::instance()->findActiveUserById($item->getSenderId()); $mailinglist = MailinglistTemplateTable::instance()->getMailinglistByVersionId($item->getMailinglisttemplateversionId()); $inProgress = createDayOutOfDateSince($item->getVersioncreatedAt()); $inProgress = addColor($inProgress, $userSettings['markred'],$userSettings['markorange'],$userSettings['markyellow']); $userdata = $sender[0]->getUserData()->toArray(); $username = $sender[0]->getUsername() . ' (' . $userdata['firstname'] . ' ' . $userdata['lastname'] . ')'; $result[$a]['#'] = $counter++;; $result[$a]['id'] = $item->getId(); $result[$a]['mailinglisttemplate_id'] = $item->getMailinglisttemplateversionId(); $result[$a]['mailinglisttemplate'] = $mailinglist[0]->getName(); $result[$a]['sender_id'] = $item->getSenderId(); $result[$a]['sendername'] = $username; $result[$a]['name'] = $item->getName(); $result[$a]['isstopped'] = $item->getIsstopped(); $result[$a]['process'] = $this->getProcess($item->getActiveversionId()); $result[$a]['auth'] = $authSettings->getRights($item->getMailinglisttemplateversionId(), $item->getActiveversionId()); if($item->getIscompleted() == 0 OR $item->getIscompleted() == '') { $result[$a]['iscompleted'] = 0; } else { $result[$a]['iscompleted'] = 1; $result[$a]['process'] = '<div style="background-color:#00FF00; width:100px;">100 %'.'</div>'; } $result[$a]['workflowisstarted'] = $item->getWorkflowisstarted(); if($item->getIsstopped() == 1) { $result[$a]['currentstation'] = '<table><tr><td width="16"><img src="/images/icons/circ_stop.gif" /></td><td>'.$this->context->getI18N()->__('Workflow stopped' ,null,'workflowmanagement').'</td></tr></table>'; $result[$a]['currentlyrunning'] = '-'; $result[$a]['stationrunning'] = '-'; // $result[$a]['process'] = '-'; } elseif($item->getIscompleted() == 1) { $result[$a]['currentstation'] = '<table><tr><td width="16"><img src="/images/icons/circ_done.gif" /></td><td>'.$this->context->getI18N()->__('Workflow completed' ,null,'workflowmanagement').'</td></tr></table>'; $result[$a]['currentlyrunning'] = '-'; $result[$a]['stationrunning'] = '-'; } elseif($item->getWorkflowisstarted() == 0) { $startdateofWorkflow = date('Y-m-d',$item->getStartworkflowAt()); $startdateofWorkflow = format_date($startdateofWorkflow, 'p', $this->culture); $result[$a]['currentstation'] = '<table><tr><td width="16"><img src="/images/icons/circ_waiting.gif" /></td><td>'.$this->context->getI18N()->__('Startdate' ,null,'workflowmanagement').': '.$startdateofWorkflow.'</td></tr></table>'; $result[$a]['currentlyrunning'] = '-'; $result[$a]['stationrunning'] = '-'; } else { $stationSettings = $this->getCurrentStation($item->getActiveversionId(), $item->getSenderId()); if(!empty($stationSettings)) { $result[$a]['currentstation'] = $stationSettings[0]; $result[$a]['currentlyrunning'] = '<table><tr><td width="20">' . $inProgress . ' </td><td>' . $this->context->getI18N()->__('Day(s)' ,null,'workflowmanagement') . '</td></tr></table>'; $slotRunning = createDayOutOfDateSince($stationSettings[1]); $slotRunning = addColor($slotRunning, $userSettings['markred'],$userSettings['markorange'],$userSettings['markyellow']); $result[$a]['stationrunning'] = '<table><tr><td width="20">' . $slotRunning . ' </td><td>' . $this->context->getI18N()->__('Day(s)' ,null,'workflowmanagement') . '</td></tr></table>'; } else { $result[$a]['currentstation'] = '-'; $result[$a]['currentlyrunning'] = '-'; $result[$a]['stationrunning'] = '-'; } } if($item->getIsarchived() == 1) { $result[$a]['currentstation'] = '<table><tr><td width="16"><img src="/images/icons/circ_archived.gif" /></td><td>'.$this->context->getI18N()->__('Workflow archived' ,null,'workflowmanagement').'</td></tr></table>'; $result[$a]['currentlyrunning'] = '-'; $result[$a]['stationrunning'] = '-'; } $result[$a]['userdefined1'] = $this->getFields('userdefined1',$item->getActiveversionId()); $result[$a]['userdefined2'] = $this->getFields('userdefined2',$item->getActiveversionId()); $result[$a]['versioncreated_at'] = format_date($item->getVersioncreatedAt(), 'g', $this->culture); $result[$a++]['activeversion_id'] = $item->getActiveversionId(); } #print_r ($result);die; return $result; }
<br /> <input type="submit" value="校准对角线" /> <a href="index.php">复位</a> </form> <div class="resultBox"> <div id="error"><?php echo $error; ?> </div> <?php if (isset($result)) { // 高亮误差较大的结果 $status = addColor(FALSE !== strstr($result['status'], 'OK'), $result['status']); $diffX = addColor($result['diff'][0] <= 5, $result['diff'][0]); $diffY = addColor($result['diff'][1] <= 5, $result['diff'][1]); echo <<<HTML <p><span>计算结果</span>: {$status}</p> <br /> <p><span>对角线 X</span>: {$result['X']}</p> <p><span>差值</span>: {$diffX}</p> <br /> <p><span>对角线 Y</span>: {$result['Y']}</p> <p><span>差值</span>: {$diffY}</p> <br /> HTML; } else { echo "<p>请输入所有数值,然后点击 [校准对角线] </p><br />"; }
function htmlRecettes() { $retour = ""; $tr = "<tr class='mh_tdtitre' align='center'>"; $recettes = getEMRecettes()->getElementsByTagName("Recette"); foreach ($recettes as $i => $recette) { $couleur = "red"; if ($recette->getAttribute("statut") != "INCOMPLET") { $couleur = "green"; } $td = "<td class='mh_tdpage' style='border: 1px solid #F9BB2F;' onClick=\"location.href='view_recette.php?id=" . $i . "'\" onMouseOut=\"this.style.backgroundColor = '#30385C';\" onMouseOver=\"this.style.backgroundColor = '#F9BB2F';this.style.cursor='pointer'\">"; if ($i % 4 == 0) { $retour .= $tr; } $retour .= $td; $retour .= "<h2>" . utf8_decode($recette->getAttribute("nom")) . "</h2>"; $retour .= "<h3 style='display:inline;color:{$couleur};'>" . $recette->getAttribute("statut") . "</h3><br/><br/>"; $retour .= "Chance de réussite : " . addColor($recette->getAttribute("ratio") . "%"); $retour .= "</td>"; if ($i % 4 == 3) { $retour .= "</tr>"; } } return $retour; }