Location: PHPKode > projects > RepMan > repman/inc/jo.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>Job management</title>
  <link rel="stylesheet" href="sc/style.css" type="text/css">
</head>
<body>
<br>
  <div id="menu">
    <?
      require ('inc/menu.php');
      $view = 1;      
    ?>
  </div>
  <?
    ConnectIt();
    if (isset($_GET["edit"])&&isset($_GET["sch"])) {
      $editace = 1;
      $schedn = $_GET["sch"]+0;    // bezpecne ulozeni identifikatoru planu
      if ($schdata = Query("SELECT * FROM scheduler WHERE id='$schedn';")) {  // nacitam co budu editovat
        $schlist = $schdata[0];
        $schcl = $schlist[1];   // ukladam id klienta
        $schjo = $schlist[2];   // ukladam id typu jobu
        if ($schlist[3] == 1) {   // rozliseni typu doW/doM
          $scht = 0;
        } else {
          $scht = 1;
        }
      } else {
        $schedn = 0;
        $schcl = 0;
        $schjo = 0;
        $scht = 0;
      }
    } else {
      $editace = 0;
      $schedn = 0;
    }
    /*       pridavani noveho planu        */
    if (isLoggedIn()&&(!isset($_GET["jobtype"]))&&(!isset($_GET["plan"]))&&((isset($_GET["new"])&&($_GET["new"] == 1))||($editace == 1))):
      $view = 0;      
      if ($editace == 0) {
        echo "<h1>Add new plan</h1><small>Adding new plan to a scheduler</small>\n";
      } else {
        echo "<h1>Edit job</h1><small>Editing job from a scheduler</small>\n";        
      }
      if (!$cli=Query("SELECT * FROM client ORDER BY name;")) {
        echo "<div class=\"info\"><p><u>No client found</u><br>\nTo make new plan, you must <a href=\"clients.php?new=1\">add client</a> first.</p></div>\n";
        logerr("Problem with SELECT 'client' table. Query in Add new plan. No client found.");
      }  
      if (!$jb=Query("SELECT * FROM job ORDER BY job;")) {
        echo "<div class=\"info\"><p><u>No job-type found</u><br>\nBefore make new plan, you must <a href=\"jobs.php?new=1&jobtype=1\">add</a> at least one <a href=\"jobs.php?new=1&jobtype=1\">job-type</a>.</p></div>\n";
        logerr("Problem with SELECT 'job' table. Query in Add new plan. No job-type found.");
      }
      if ($cli && $jb) {
  ?>
    <!--       formular pro zadavani noveho planu       -->
    <form action="jobs.php" method="get" accept="text/html" class="frm">
    <?  if ($editace) {
          echo "<input type=\"hidden\" name=\"sch\" value=\"$schedn\">\n";
          echo "<input type=\"hidden\" name=\"edit\" value=\"1\">\n";
          echo "<input type=\"hidden\" name=\"plan\" value=\"1\">\n";
        } else {
          echo "<input type=\"hidden\" name=\"plan\" value=\"1\">\n";
        }
    ?>
    
    <div class="item">                          <!-- Jmeno klienta -->
      <label for="fclient">Client</label><br>
      <select name="fclient" size="1">
        <?
          foreach($cli as $n) {
            if ($n[0]==$GLOBALS["test_client_id"]) { continue; } else {
              echo "<option value=\"$n[0]\" ";
              if ($schcl == $n[0]) { 
                echo "selected";  
              }
              echo ">".$n[1]."</option>\n";
            }
          }        
        ?>
      </select>&nbsp;<a href="clients.php?new=1" title="Add new client">+</a>
    </div>
    
    <div class="item">                          <!-- Typ jobu -->
      <label for="fjob">Job spec.</label><br>
      <select name="fjob" size="1">
        <?
          foreach($jb as $n) {
            if ($n[0]==$GLOBALS["test_job_id"]) { continue; } else {
              echo "<option value=\"$n[0]\" ";
              if ($schjo == $n[0]) { 
                echo "selected";  
              }
              echo ">".$n[1]."</option>\n";
            
              //echo "<option value=\"$n[0]\">".$n[1]."</option>";
            }
          }        
        ?>
      </select>&nbsp;<a href="jobs.php?new=1&jobtype=1" title="Add new job-type">+</a>
    </div>
    
    <fieldset class="item">
      <legend>Choose schedule type</legend>
      <input type="radio" name="type" value="1" class="radio"<? if ($scht == 0) { echo " checked=\"true\""; }?>><strong>Day of Week</strong><br>
      <input type="radio" name="type" value="2" class="radio"<? if ($scht == 1) { echo " checked=\"true\""; }?>><strong>Day of Month</strong><br>
    </fieldset>
        
    <input type="submit" value="send" class="item">

    </form><br>
  
  <?    
      } else {
        echo "<div class=\"info\"><p>The planning of jobs is depending on setting client and job-type.</p></div>";
      }
      
    /*            upresneni typu jobu pro zpracovani formulare           */
    elseif (isLoggedIn()&&isset($_GET["plan"])&&$_GET["plan"]):
      if (isset($_GET["type"])): /* je nastaven GET typu */
  ?>
    <!--       formular pro zadavani noveho planu       -->
    <?
        if ($_GET["type"]==1):
          $view = 0;      
          if (!$editace) {
            echo "<h1>Specify schedule</h1><small>Adding new job - Days of Week</small>\n";  
          } else {
            echo "<h1>Specify schedule</h1><small>Editing job - Days of Week</small>\n";
            $schwplan = $schlist[4];   // ukladam plan jobu
          }
    ?>
    <form action="jobs.php" method="post" accept="text/html" class="frm">
    <?    if ($editace) {
            echo "<input type=\"hidden\" name=\"update\" value=\"1\">\n";
            echo "<input type=\"hidden\" name=\"schedn\" value=\"$schedn\">\n";
          } else {
            echo "<input type=\"hidden\" name=\"insert\" value=\"1\">\n";
          }
    ?>
    <input type="hidden" name="fclient" value="<? echo $_GET["fclient"]; ?>">
    <input type="hidden" name="fjob" value="<? echo $_GET["fjob"];?>">
    <input type="hidden" name="type" value="1">

    <div class="item">                          <!-- Vyber dnu v tydnu -->
      <label for="fdow"align="texttop">Day of Week</label><br>
      <select name="fdow[]" size="7" multiple="multiple">      
      <?
          $week = $GLOBALS["week_long"];
          for ($i=0; $i<=6; $i++) {
            echo "<option value=\"$i\"";
            if ($editace == 1) {
              $pindex = $i*2;
              if ($schwplan[$pindex] == '1') {
                echo " selected";
              }
            }
            echo ">$week[$i]</option>\n";
          }   
      ?>
      </select>
    </div>
        
    <input type="submit" value="send" class="item">

    </form><br>

    <?
        elseif ($_GET["type"]==2):
          $view = 0;      
          if (!$editace) {
            echo "<h1>Specify schedule</h1><small>Adding new job - Day of Month</small>\n";  
          } else {
            echo "<h1>Specify schedule</h1><small>Editing job - Day of Month</small>\n";
            $schdaynumber = $schlist[5];   // ukladam cislo dne
            $schmplan = $schlist[6];   // ukladam plan jobu
          }
    ?>
    <form action="jobs.php" method="post" accept="text/html" class="frm">
    <?    if ($editace) {
            echo "<input type=\"hidden\" name=\"update\" value=\"1\">\n";
            echo "<input type=\"hidden\" name=\"schedn\" value=\"$schedn\">\n";
          } else {
            echo "<input type=\"hidden\" name=\"insert\" value=\"1\">\n";
          }
    ?>
    <input type="hidden" name="fclient" value="<? echo $_GET["fclient"]; ?>">
    <input type="hidden" name="fjob" value="<? echo $_GET["fjob"];?>">
    <input type="hidden" name="type" value="2">

    <div class="item" id="DoM">                          <!-- Vyber dnu v mesici -->
    <label for="fdom">Day of Month</label><br>
    <select name="fdom" size="20">
    <optgroup label="Ordinal">
    <?
      for ($a=1; $a<=31; $a++) {
      	echo "<option value=\"$a\"";
      	if ($editace) {
          if ($schdaynumber == $a) {
            echo " selected";
          }
        }
        echo ">...........$a</option>\n";
      }
    ?>
    </optgroup>
    <optgroup label="Specific">
    <?
      $wd = $GLOBALS["week_short"];
      $i = 40;
      foreach ($wd as $w) {
      	echo "<option value=\"".$i++."\"";
      	if ($editace) {
          if ($schdaynumber == ($i - 1)) {
            echo " selected";
          }
        }
        echo ">1st $w</option>\n";
      }
      echo "</optgroup>\n<optgroup label=\"Following\">\n";    
      $i = 50;
      foreach ($wd as $w) {
      	echo "<option value=\"".$i++."\"";
      	if ($editace) {
          if ($schdaynumber == ($i - 1)) {
            echo " selected";
          }
        }      	
        echo ">next $w</option>\n";
      }    
    ?>
    </optgroup>
    </select>
    <br>
    <small>! <strong>Attention</strong> on February<br>and months with 30 doM.</small>
    </div>
    
    <div class="item" id="SM">
    <label for="mon[]">Concrete Month</label><br>
    <select name="mon[]" size=12 multiple>
      <?
        $m = array ("January","February","March","April","May","June","July","August","September","October","November","December");
        if ($editace) {
          for ($i=0; $i<=11; ) {
            $pindex = $i*2;

            echo "<option value=\"".++$i."\"";
            if ($schmplan[$pindex] == '1') {
              echo " selected";
            }
            echo ">".$m[$i-1]."</option>\n";
          }
        } else {
          for ($i=0; $i<=11; ) {
          	echo "<option value=\"".++$i."\" selected>".$m[$i-1]."</option>\n";
          }        
        }       
      ?>
    </select>
    </div>
    <input type="submit" value="send" class="item">

    </form><br>    
    <?
        endif;
      else:
        echo "Unrecognized type of schedule.";
        logerr("Unrecognized type of schedule - type == ".$_GET["type"]);
      endif;
    ?>
  
  <?
    elseif (isLoggedIn() && isset($_GET["del"]) && $_GET["del"]):           // DELeting of scheduler plans
      $todel = $_GET["del"]+0;
      $todel_ok = 0;
      if ($jd = Query("SELECT scheduler.id,client.name,job.job FROM scheduler LEFT JOIN (client,job) ON (client.id = scheduler.client_id AND job.id = scheduler.job_id);")) {
        logdebug("Hledam job pro smazani. ID == $todel");
        foreach ($jd as $jl) {
          if ($jl[0] == $todel) {     // test existence planu
            $todel_ok = 1;
            $jobident[0] = $jl[1];
            $jobident[1] = $jl[2];
          }
        }
      } else {
        echo "Couldn't select jobs to remove.";
        logerr("Nepodarilo se vybrat seznam jobu pred smazanim.");
      }
      if ($todel_ok) {
        $view = 0;
  ?>
        <h1>Remove plan</h1>
        <form action="jobs.php" method="post" accept="text/html">
          <div class="question"><h3>Are you sure?</h3>
          <p align="left"><? echo "Do You want to delete this:<br>&nbsp;<b>plan no. $todel for</b><br>&nbsp;Client:&nbsp;<b>".$jobident[0]."</b><br>&nbsp;Job-type:&nbsp;<b>".$jobident[1]."</b>"; ?> </p><br>
          
          <input type="checkbox" name="delete" value="<? echo $todel; ?>"><label for="delete">Yes, I want to delete this job plan.</label>
          <input type="submit" value="submit" name="submit">
          </div>
        </form>
  <?
      } else {
        $view = 1;
        echo "<div class=\"info\"><p align=\"center\">Couldn't find job id = $todel.</p></div>\n";
      }

    elseif (isLoggedIn() && isset($_POST["delete"])):
      if ($_POST["delete"] && Query("DELETE FROM scheduler WHERE id=".$_POST["delete"].";")) {
        $view = 1;
        echo "<div class=\"info\"><p align=\"center\">Plan id = ".$_POST["delete"]." was successfully removed.</p></div>\n";
        logdebug("Uspesne smazani jobu id = ".$_POST["delete"]);        
      } else {
        $view = 1;
        echo "<div class=\"info\"><p align=\"center\">Cann't remove plan id = ".$_POST["delete"]."</p></div>\n";
      }

    elseif (isLoggedIn()&&(isset($_POST["insert"])||isset($_POST["update"]))&&($_POST["insert"]||$_POST["update"])&&isset($_POST["type"])&&(!isset($_GET["jobtype"]))):
      /*            zpracovani formulare pro zadani noveho jobu           */
      
  ?>
  <div class="info">
  <p align="center">  
  <?
      /*    kontrola spravneho zadani   */
      if ((!isset($_POST["fdow"]))&&((!isset($_POST["fdom"]))||($_POST["fdom"]=="")||(!isset($_POST["mon"])))) {
        echo "There is no time-plan scheduled. Make your choice again.";
        echo "cl==".$_POST["fclient"]." jb==".$_POST["fjob"]."<br>";
        logerr("No time-plan scheduled.");
        loginput($_POST["fclient"]." ".$_POST["fjob"]);
      } else {
        
        /*      Day of Week     */
        if (isset($_POST["fdow"])) { 
          $dow="";
          for ($i=0; $i<=6; $i++) {   // vytvoreni retezce den tecka. cislo dni 0-6
            foreach ($_POST["fdow"] as $w) {    // test, zda je cislo dne obsazeno ve vyberu
              if ($w == $i) {
                $dow .= "1";
              }
            }
            if ($dow == "") {   // pokud prvni den neni vybran, je nutno retezec zalozit az zde
              $dow = "0";
            }
            if (strlen($dow)==(2*$i+1)) {   // pokud je jiz pridano nove cislo
              if ($i<6) {                   // a pokud neni posledni den
                $dow .= ".";                // pridej tecku
              }
            } else {                        // jinak pridej nulu
              if ($i<6) {
                $dow .= "0.";               // s teckou
              } else {
                $dow .= "0";                // v pripade posledniho dne bez tecky
              }
            }
          }
          
          $cli = $_POST["fclient"];
          $jb = $_POST["fjob"];
          if (isset($_POST["insert"])) {
            if (Query("INSERT INTO scheduler(client_id,job_id,type,doW) VALUES($cli,$jb,1,'$dow');")) {
              echo "DoW plan = '$dow' was successfully saved.<br>";
              loginput("Client: $cli, Job: $jb, Planning type: 1, Plan: '$dow'");
            } else {
              echo "DoW plan '$dow' can not be saved :( There is a problem.<br>";
              logerr("DoW plan '$dow' can not be saved :( There is a problem at INSERT INTO scheduler.");
              loginput("Client: $cli, Job: $jb, Planning type: 1, Plan: '$dow'");
              logdebug("The Query is: "."INSERT INTO scheduler(client_id,job_id,type,doW) VALUES($cli,$jb,1,'$dow');");
            }
          } else {
            if (Query("UPDATE scheduler SET client_id=$cli,job_id=$jb,type=1,dow='$dow' WHERE id='".$_POST["schedn"]."';")) {
              echo "DoW plan = '$dow' was successfully saved.<br>";
              loginput("Client: $cli, Job: $jb, Planning type: 1, Plan: '$dow'");
            } else {
              echo "DoW plan '$dow' can not be saved :( There is a problem.<br>";
              logerr("DoW plan '$dow' can not be saved :( There is a problem at INSERT INTO scheduler.");
              loginput("Client: $cli, Job: $jb, Planning type: 1, Plan: '$dow'");
              logdebug("The Query is: "."INSERT INTO scheduler(client_id,job_id,type,doW) VALUES($cli,$jb,1,'$dow');");
            }            
          }
        }        
        
        /*      Day of Month      */
        if (isset($_POST["fdom"])&&$_POST["fdom"]!=""&&(isset($_POST["mon"]))) {
          $dom = $_POST["fdom"];
          $dom += 0;
          loginput("dom==".$dom);
          if (count($_POST["mon"])==12) {
            $cli = $_POST["fclient"];
            $jb = $_POST["fjob"];
            $type = 2;      // scheduler.type = 2 (every months)
            $mon = '1.1.1.1.1.1.1.1.1.1.1.1';
            if (isset($_POST["insert"])) {
              if (Query("INSERT INTO scheduler(client_id,job_id,type,doM,mon) VALUES($cli,$jb,$type,$dom,'$mon');")) {
                echo "DoM plan (day of month: $dom, months: '$mon') was successfully saved <br>\n";
                loginput("Client: $cli, Job: $jb, Day: $dom, Month: '$mon', Type == $type (DoM - every)");
              } else {
                echo "DoM plan '$mon' can not be saved. <br> There is a problem <br>\n";
                logerr("Problem in Query INSERT INTO scheduler, doM, type - every");              
                loginput("Client: $cli, Job: $jb, Day: $dom, Month: '$mon', Type == $type (DoM - every)");
              }
            } else {
              if (Query("UPDATE scheduler SET client_id=$cli,job_id=$jb,type=$type,doM=$dom,mon='$mon' WHERE id='".$_POST["schedn"]."';")) {
                echo "DoM plan (day of month: $dom, months: '$mon') was successfully updated <br>\n";
                loginput("Client: $cli, Job: $jb, Day: $dom, Month: '$mon', Type == $type (DoM - every)");
              } else {
                echo "DoM plan '$mon' can not be saved. <br> There is a problem <br>\n";
                logerr("Problem in Query INSERT INTO scheduler, doM, type - every");              
                loginput("Client: $cli, Job: $jb, Day: $dom, Month: '$mon', Type == $type (DoM - every)");
              }
            }
          } else {
            $mon = "";
            for ($i=1; $i<=12; $i++) {
              foreach ($_POST["mon"] as $m) {   // test jestli cislo mesice je ve vyberu
                if ($m == $i) {
                  $mon .= "1";
                }
              }
              if ($mon == "") {       // prvni cislo mesice nebylo vybrano 
                $mon = "0";           // musim priradit nulu
              }
              if (strlen($mon)==(2*$i-1)) {
                if ($i<12) {
                  $mon .= ".";
                }
              } else {
                if ($i<12) {
                  $mon .= "0.";
                } else {
                  $mon .= "0";
                }
              }
            }
            $cli = $_POST["fclient"];
            $jb = $_POST["fjob"];
            $type = 3;      // scheduler.type = 3 (selected months)
            if (isset($_POST["insert"])) {
              if (Query("INSERT INTO scheduler(client_id,job_id,type,doM,mon) VALUES($cli,$jb,$type,$dom,'$mon');")) {
                echo "DoM plan (day of month: $dom, months:&nbsp;&nbsp;'$mon') was successfully saved <br>\n";
                loginput("Client: $cli, Job: $jb, Day: $dom, Month: '$mon', Type == $type (DoM - every)");
              } else {
                echo "DoM plan '$mon' can not be saved. <br> There is a problem <br>\n";
                loginput("Client: $cli, Job: $jb, Day: $dom, Month: '$mon', Type == $type (DoM - every)");
                logerr("Problem in Query INSERT INTO scheduler, doM, type - selected.");
                $l = "";
                foreach ($_POST["mon"] as $m) {
                  $l .= $m.".";
                }
                loginput($l);
              }
            } else {
              if (Query("UPDATE scheduler SET client_id=$cli,job_id=$jb,type=$type,doM=$dom,mon='$mon' WHERE id='".$_POST["schedn"]."';")) {
                echo "DoM plan (day of month: $dom, months: '$mon') was successfully updated <br>\n";
                loginput("Client: $cli, Job: $jb, Day: $dom, Month: '$mon', Type == $type (DoM - every)");
              } else {
                echo "DoM plan '$mon' can not be saved. <br> There is a problem <br>\n";
                loginput("Client: $cli, Job: $jb, Day: $dom, Month: '$mon', Type == $type (DoM - every)");
                logerr("Problem in Query INSERT INTO scheduler, doM, type - selected.");
                $l = "";
                foreach ($_POST["mon"] as $m) {
                  $l .= $m.".";
                }
                loginput($l);
              }            
            }
          }
        }
      }
  ?>
  </p>  
  </div>  
  <?
    elseif (isset($_GET["jobtype"])):  
      if (!isset($_GET["new"])&&!isset($_GET["edit"])) {
        if (isLoggedIn()&&(isset($_POST["insert"])||(isset($_POST["update"])&&isset($_POST["jtindex"])))) {
          if ($_POST["tname"]) {
            $view = 1;      
            $jt_ok = 1;
            foreach (Query("SELECT job FROM job ORDER BY job;") as $j) {
                	if ($j[0] == $_POST["tname"]) {
                    $jt_ok = 0;
                  }
            }
            if ($jt_ok) {
              if (isset($_POST["insert"])) {
                if (Query("INSERT INTO job(job) VALUES('".mysql_escape_string($_POST["tname"])."');")) {
                  echo "<div class=\"info\"><p>New job type ".$_POST["tname"]." was successfully saved.</p></div>";
                } else {
                  echo "There is a problem with inserting new type to DB.<br>";
                  logerr("Problem with INSERT INTO job name ==".$_POST["tname"]);
                  loginput($_POST["tname"]." caused a problem");
                }
              } elseif (isset($_POST["update"])) {
                if (Query("UPDATE job SET job='".mysql_escape_string($_POST["tname"])."' WHERE id=".$_POST["jtindex"].";")) {
                  echo "<div class=\"info\"><p>Job type ".$_POST["tname"]." has been successfully updated.</p></div>";
                } else {
                  echo "There is a problem with updating type to DB.<br>";
                  logerr("Problem with UPDATE job name ==".$_POST["tname"]);
                  loginput($_POST["tname"]." caused a problem");
                }
              }
            } else {
              echo "<div class=\"info\"><p>I can not save new type - ".$_POST["tname"].". This job type exists.</p></div>";
            }
          } else {
            echo "<div class=\"info\"><p><strong>Cann't save new job type</strong><br>New job type name is empty!!!</p></div>";
          }
        }
      } elseif(isLoggedIn()) {
        $view = 0;
      }
      if ($view==1):
  ?>
    <!-- aaaaaaaaaaaaaaaaaaaaaaaa  view/edit job types  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -->
    <h1>Job types</h1>
    <?
        if ($jbdt = Query("SELECT * FROM job ORDER BY id;")) {
    ?>
    <ul class="no_dec">
    <li>&nbsp;&nbsp;&nbsp;<u>ID</u>&nbsp;&nbsp;&nbsp;<u>Type name</u></li>
  <?
          foreach ($jbdt as $jbls) {
            echo "<li>".sayifadmin("<a href=\"?jobtype=1&edit=1&jt=".$jbls[0]."\" title=\"Edit\">~</a>",1)."&nbsp;&nbsp;".$jbls[0].str_repeat("&nbsp;",4).$jbls[1]."</li>\n";
          }  
          echo sayifadmin("<li>&nbsp;&nbsp;&nbsp;<a href=\"?jobtype=1&new=1\" title=\"Add new\">+</a></li>",0)."</ul>";
        } else {
          if (isLoggedIn()) {
            echo "<div class=\"info\"><p><u>No job-type defined</u><br>\nFor begin of using RepMan, you should to <a href=\"?new=1&jobtype=1\" title=\"Add new job-type\">add job-type</a>.</p></div>\n";
          } else {
            echo "<div class=\"info\"><p><u>No job-type defined</u><br>\nFor begin of using RepMan, you should to add job-type.<br>\nIf you want to do this, you must <a href=\"?admin=1\" title=\"Log in as administrator\">log in as Repman's administrator</a></p></div>\n";        
          }  
        }
      elseif(isLoggedIn()&&isset($_GET["new"])):
  ?>
    <h1>Add new job-type</h1>
    <small>Adding new type of job</small>
    <form action="jobs.php?jobtype=1" method="post" accept="text/html" class="frm">
      <input type="hidden" name="insert" value="1">
      <div class="item">
        <label for="tname">New job type</label><br>
        <input type="text" name="tname" maxlength="17"><br>
      </div>
      <input type="submit" value="send" class="item">
    </form>
  <?
      elseif(isLoggedIn()&&isset($_GET["edit"])):
        if ($jtd=Query("SELECT * FROM job WHERE id=".mysql_escape_string($_GET["jt"]).";")) {
          $jtl = $jtd[0];
  ?>
    <h1>Edit job type</h1>
    <small>Editing type of job</small>
    <form action="jobs.php?jobtype=1" method="post" accept="text/html" class="frm" name="editfrm">
      <input type="hidden" name="update" value="1">
      <input type="hidden" name="jtindex" value="<? echo $jtl[0]; ?>">
      <div class="item">
        <label for="tname">Edit job type</label><br>
        <input type="text" name="tname" maxlength="17" value="<? echo $jtl[1]; ?>"><br>
      </div>
      <input type="submit" value="send" class="item">
    </form>
  <?
        }
      endif;
    endif;  
    if(!isset($_GET["jobtype"])&&$view==1):  
  ?>
  
  <?
    /*
    	if ((!isset($_GET["add"])&&$_GET["add"]!=1)&&(!isset($_GET["new"])&&$_GET["new"]!=1)&&(!isset($_GET["jobtype"])&&$_GET["jobtype"]!=1)):
    */
    /*            vychozi je prehled jobu           */
  ?>
  <h1>Plan management</h1>  
  <ul class="no_dec">
  <?
      if ($list = Query("SELECT client.name,job.job,type,doW,doM,mon,client.id,job.id,scheduler.id FROM scheduler LEFT JOIN (client,job) ON (client.id=scheduler.client_id AND job.id=scheduler.job_id);")) {
        echo "<li>".sayifadmin("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<u class=\"not_imp\">IDs</u>&nbsp;&nbsp;&nbsp;&nbsp;",1)."<u>Client</u>".str_repeat("&nbsp;", 11)."<u>Job</u>".str_repeat("&nbsp;", 15)."<u>Day of Week</u>".str_repeat("&nbsp;", 4)."<u>Day of Month</u>&nbsp;&nbsp;<u>Month</u></li>\n";
        foreach ($list as $sched) {
          echo "<li>".sayifadmin("<a href=\"?del=$sched[8]\" title=\"Remove\">-</a>&nbsp;<a href=\"?edit=1&sch=$sched[8]\" title=\"Edit\">~</a>&nbsp;&nbsp;<span class=\"not_imp\">",0);  // odkaz editace
    
          if ($sched[6]<10) {                                 // zobrazeni IDcek
            echo sayifadmin("&nbsp;".$sched[6].".",0);      
          } else {
            echo sayifadmin($sched[6].".",0);
          }
          if ($sched[7]<10) {
            echo sayifadmin($sched[7].".e&nbsp;",0);      
          } else {
            echo sayifadmin($sched[7].".e",0);
          }
          echo sayifadmin("</span>",0);
    
          echo "&nbsp;".$sched[0].str_repeat("&nbsp;", 16-strlen($sched[0]));     // klient
          
          echo "&nbsp;".$sched[1].str_repeat("&nbsp;", 18-strlen($sched[1]));   // jobtype a typ
    
          if ($sched[2]==1) {         // day of week and day of month
            echo $sched[3];
            echo "<span class=\"not_imp\">".str_repeat("&nbsp;", 15-strlen($sched[3])).str_repeat("&nbsp;",4).$sched[4].str_repeat("&nbsp;", 9).$sched[5]."</span>"."</li>\n";
          } else {
            echo "<span class=\"not_imp\">".$sched[3]."</span>";
            echo str_repeat("&nbsp;", 2);
            if ($sched[4]<39) {
              echo str_repeat("&nbsp;",4).Ordinal($sched[4]).str_repeat("&nbsp;", 8-strlen($sched[4])).$sched[5]."</li>\n";
            } else {
              $wd = $GLOBALS["week_short"];
              if ($sched[4]<50) {
                $wdi = $sched[4]-40;
                echo str_repeat("&nbsp;", 4)."1st&nbsp;".$wd[$wdi]."&nbsp;&nbsp;&nbsp;".$sched[5]."</li>\n";
              } else {
                $wdi = $sched[4]-50;
                echo str_repeat("&nbsp;", 4)."next&nbsp;".$wd[$wdi]."&nbsp;&nbsp;".$sched[5]."</li>\n";          
              }
            }
          }
        }
        echo "<li>".sayifadmin("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"?new=1\" title=\"Add new\">+</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",1).str_repeat("&nbsp;", 35)."S M T W T F S".str_repeat("&nbsp;", 16)."J F M A M J J A S O N D</li>\n</ul>";
      } else {
        if (isLoggedIn()) {
          echo "<div class=\"info\"><p><u>No plan defined</u><br>\nIf you want to check periodically running jobs<br>\nand you want to have information about non-started jobs,<br>\nyou should to <a href=\"?new=1\" title=\"Add new plan\">make plan</a>.</p></div>\n";
        } else {
          echo "<div class=\"info\"><p><u>No plan defined</u><br>\nIf you want to check periodically running jobs<br>\nand you want to have information about non-started jobs,<br>\nyou should to make plan.<br>\nIf you want to do this, you must <a href=\"?admin=1\" title=\"Log in as administrator\">log in as Repman's administrator</a>.</p></div>\n";        
        }  
      }
    endif;
  ?>
</body>
</html>
Return current item: RepMan