<?php

include "local.php";
$sf = new scaffold("pedidos_paso");
$sf->open($r->id);
$sf->delete();
print_arr(errorobject::errorlist());
echo "ok";
Example #2
0
$sf->open($r->pedido_id);
$p = new aworkspage();
if ($r->fecha_entrega_prevista_day) {
    $sfe = new scaffold("pedidos_eventos");
    $sfe->fromObject($r);
    $sfe->estado_viejo = $sf->estado;
    $d = new date();
    $d->day = $r->fecha_entrega_prevista_day;
    $d->month = $r->fecha_entrega_prevista_month;
    $d->year = $r->fecha_entrega_prevista_year;
    $d->parse();
    $sfe->fecha_entrega_prevista = $d->timestamp;
    $sfe->fecha = time();
    $sfe->idpedido = $r->pedido_id;
    $sfe->insert();
    if (!errorobject::hasErrors()) {
        $sf->estado = $sfe->estado_nuevo;
        $sf->fecha_entrega_prevista = $sfe->fecha_entrega_prevista;
        if ($sfe->estado_nuevo == 8) {
            $sf->fecha_entrega = time();
        }
        $sf->update();
        header("location:pedido.php?pedido_id=" . $r->pedido_id);
    } else {
        $p->addWidget(new infobox("Error", "Error en el formulario, compruebe los datos", false));
    }
}
error_reporting(E_ALL);
$p->addWidget(html::write("<h1>A&ntilde;adir evento a pedido <b>" . $sf->referencia . "</b> de <b>" . $sf->cliente . "</b> </h1>"));
$b = new Box("Datos del Evento");
$t = new toolbar();
Example #3
0
if ($r->referencia) {
    $sf = new scaffold("pedidos");
    $sf->fromObject($r);
    $sf->estado = 0;
    $d = new date();
    $d->day = $r->entrega_prevista_day;
    $d->month = $r->entrega_prevista_month;
    $d->year = $r->entrega_prevista_year;
    $d->parse();
    $sf->fecha_entrega_prevista = $d->timestamp;
    $sf->fecha_pedido = time();
    $sf->fecha_entrega = -1;
    $tracking = "AW/" . date("y") . date("w") . "/" . strtoupper(substr(md5(uniqid(rand)), 4, 2) . substr(md5(uniqid(rand)), 7, 2) . substr(md5(uniqid(rand)), 12, 2));
    $sf->tracking = $tracking;
    $sf->insert();
    if (errorobject::haserrors()) {
    } else {
        $id = mysql_insert_id();
        header("location:pedido.php?pedido_id=" . $id);
    }
}
$p = new aworkspage();
$b = new Box("A&ntilde;adir Pedido");
$p->addWidget(html::write("<h1>A&ntilde;adir Pedido</h1>"));
$t = new toolbar();
$t->addWidget(new button("Guardar Pedido", "javascript:document.forms[0].submit()", "add"));
$b->addWidget($t);
$f = new form("", "");
$f->addWidget(new form_separator("Referencia y Cliente"));
$f->addWidget(new form_input("referencia", "Referencia Cliente", $r->referencia));
$f->addWidget(new form_input("cliente", "Cliente", $r->cliente));
Example #4
0
 function predrawWidget()
 {
     $identificator = $this->name;
     $action = $this->name . "_action";
     $_identificator = $this->name . "_id";
     $r = new request();
     if ($r->filter_text) {
         if (strpos($this->controller, "?") === false) {
             $this->controller .= "?prepend=1";
         }
         $this->controller .= "&filter_text=" . $r->filter_text . "&filter_field=" . $r->filter_field;
         if ($r->filter_match) {
             $this->controller .= "&filter_match=1";
         }
     }
     if ($r->{$_identificator}) {
         $this->__scaffoldobject->open($r->{$_identificator});
     }
     $this->__gridobject->drop($this->__scaffoldobject);
     if ($r->{$action} == "insert") {
         $this->__scaffoldobject->fromObject($r);
     }
     $this->__formobject->drop($this->__scaffoldobject);
     switch ($r->{$action}) {
         default:
             $button_add = new button($this->button_add, $this->controller . (strpos($this->controller, "?") === false ? "?" : "&") . $action . "=add", "add");
             $b = new box($this->name ? $this->name : "List", $this->__gridobject);
             if (!$this->__disable_add) {
                 $b->addWidget($button_add);
             }
             return $b;
             break;
         case "add":
             $this->__formobject->action = $this->__formobject->action . (strpos($this->__formobject->action, "?") === false ? "?" : "&") . $action . "=insert";
             $this->__formobject->submit = $this->button_add;
             $this->__formobject->__target = $this->__formobject->action;
             return new box($this->name ? $this->name : "Add", $this->__formobject);
             break;
         case "insert":
             $this->__scaffoldobject->fromObject($r);
             if (is_array($this->__composites)) {
                 foreach ($this->__composites as $k => $v) {
                     $entity = $this->__composites[$k]["entity"];
                     $efield = $this->__composites[$k]["efield"];
                     $this->__scaffoldobject->composeField($k, $entity, $efield);
                 }
             }
             if ($this->__scaffoldobject->insert()) {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_insert_ok));
                 $t = new toolbar();
                 $b->addWidget(html::write("<script>setTimeout(\"document.location='" . $this->controller . "'\",1000);</script>"));
                 $b->addWidget($t);
                 return $b;
             } else {
                 $w = new oowidget();
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_insert_failed));
                 $b->addWidget(errorobject::errorList());
                 $this->__formobject->action = $this->__formobject->action . (strpos($this->__formobject->action, "?") === false ? "?" : "&") . $action . "=insert";
                 $this->__formobject->submit = $this->button_add;
                 $this->__formobject->__target = $this->__formobject->action;
                 $b2 = new box($this->name ? $this->name : "Add", $this->__formobject);
                 $w->addWidget($b);
                 $w->addWidget($b2);
                 $b->addWidget(new button($this->button_list, $this->controller));
                 return $w;
             }
             break;
         case "update":
             $tmpsf = $this->__scaffoldobject;
             $this->__scaffoldobject = new scaffold($this->name);
             $this->__scaffoldobject->__validators = $tmpsf->__validators;
             $this->__scaffoldobject->fromObject($r);
             if (is_array($this->__composites)) {
                 foreach ($this->__composites as $k => $v) {
                     $entity = $this->__composites[$k]["entity"];
                     $efield = $this->__composites[$k]["efield"];
                     $this->__scaffoldobject->composeField($k, $entity, $efield);
                 }
             }
             if ($this->__scaffoldobject->update()) {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_update_ok));
                 $t = new toolbar();
                 //$b->addWidget(new button($this->button_list, $this->controller));
                 $b->addWidget(html::write("<script>setTimeout(\"document.location='" . $this->controller . "'\",1000);</script>"));
                 return $b;
             } else {
                 $w = new oowidget();
                 $this->__formobject->action = $this->__formobject->action . (strpos($this->__formobject->action, "?") === false ? "?" : "&") . $action . "=update&" . $this->name . "_id=" . $r->{$_identificator};
                 $this->__formobject->__target = $this->__formobject->action;
                 $this->__formobject->submit = $this->button_update;
                 $b2 = new box($this->name ? $this->name : "View", $this->__formobject);
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_update_failed));
                 $b->addWidget(errorobject::errorList());
                 $b->addWidget(new button($this->button_list, $this->controller));
                 $w->addWidget($b);
                 $w->addWidget($b2);
                 $b->addWidget(new button($this->button_list, $this->controller));
                 return $w;
                 return $b;
             }
             break;
         case "view":
             $this->__formobject->action = $this->__formobject->action . (strpos($this->__formobject->action, "?") === false ? "?" : "&") . $action . "=update&" . $this->name . "_id=" . $r->{$_identificator};
             $this->__formobject->__target = $this->__formobject->action;
             $this->__formobject->submit = $this->button_update;
             $b = new box($this->name ? $this->name : "View", $this->__formobject);
             for ($i = 0; $i < count($this->__additionalwidgets); $i++) {
                 $b->addWidget($this->__additionalwidgets[$i]);
             }
             $t = new toolbar();
             $t->addWidget(new button($this->button_list, $this->controller, "book_previous"));
             $t->addWidget(new button($this->button_delete, $this->controller . (strpos($this->controller, "?") === false ? "?" : "&") . $action . "=delete&" . $_identificator . "=" . $r->{$_identificator}, "delete"));
             $b->addWidget($t);
             return $b;
             break;
         case "delete":
             $b = new box($this->name ? $this->name : "Delete");
             $b->addWidget(html::write($this->message_delete_confirm));
             $t = new toolbar();
             $t->addWidget(new button($this->button_delete, $this->controller . (strpos($this->controller, "?") === false ? "?" : "&") . $action . "=delete_confirm&" . $_identificator . "=" . $r->{$_identificator}, "delete"));
             $t->addWidget(new button($this->button_list, $this->controller . (strpos($this->controller, "?") === false ? "?" : "&") . $action . "=&" . $_identificator . "=" . $r->{$_identificator}, "book_previous"));
             $b->addWidget($t);
             return $b;
             break;
         case "delete_confirm":
             $this->__scaffoldobject->open($r->{$_identificator});
             if ($this->__scaffoldobject->delete()) {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_delete_ok));
                 $t = new toolbar();
                 $t->addWidget(new button($this->button_list, $this->controller));
                 $t->addWidget(html::write("<meta http-equiv=\"refresh\" content=\"1; url=" . $this->controller . "\" />"));
                 $b->addWidget($t);
                 return $b;
             } else {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_delete_failed));
                 $b->addWidget(errorobject::errorList());
                 $b->addWidget(new button($this->button_list, $this->controller));
                 return $b;
             }
             break;
     }
 }
Example #5
0
 function draw()
 {
     global $fsecuence;
     $errors = errorobject::errorParams();
     // return "<tr class=\"form_row".($fsecuence%2==0 ? "_odd":"_even")."\"><td class=\"form_row_caption\"><span class=\"form_caption\"  ".($errors[$this->name] ? "style=\"color: red;\"" : "" ).">".$this->caption."</span><br />".$this->description."</td></tr><tr><td class=\"form_row_field\"><textarea name=\"".$this->name."\"  ".($errors[$this->name] ? "style=\"border: solid 2px red;margin:-2px;\"" : "" ).">".$this->value."</textarea></td></tr>";
     $oFCKeditor = new FCKeditor($this->name);
     $oFCKeditor->BasePath = '/FCKeditor/';
     $oFCKeditor->Value = $this->value;
     $oFCKeditor->Height = $this->height;
     $oFCKeditor->Width = $this->width;
     $out .= $oFCKeditor->CreateHTML();
     return "<tr class=\"form_row" . ($fsecuence % 2 == 0 ? "_odd" : "_even") . "\"><td colspan=\"2\" class=\"form_row_field\">" . $out . "</td></tr>";
 }
Example #6
0
 function draw()
 {
     $o = $this->popMailBox();
     if (get_class($o) != "scaffold") {
         $sc = new scaffold($o->__table);
         $o->__datafields = $sc->__datafields;
     }
     $this->name = md5($this->name);
     $out .= "<form id=\"" . $this->name . "\"  class=\"" . $this->css_form . "\" method=\"post\" action=\"" . $this->action . "\">";
     $out .= "<input type=\"hidden\" name=\"" . $this->name . "_id" . "\" value=\"" . $o->id . "\" >";
     $out .= "<table>";
     $count = 1;
     $errors = errorobject::errorParams();
     foreach ($o as $k => $v) {
         if (strpos($k, "__") === false) {
             if ($this->__hidden[$k] == true) {
                 $out .= ($count % 2 == 0 ? "<tr>" : "") . "<td colspan=\"2\"><input type=\"hidden\" name=\"" . $k . "\" value=\"" . $v . "\"></td></tr>";
             } else {
                 $out .= ($count % 2 == 0 ? "<tr>" : "") . "<td class=\"dataform_title\"><b>" . ($this->__headers[$k] ? $this->__headers[$k] : $k) . "</b></td><td class=\"dataform\" style=\"padding-right:33px;\">";
                 if (is_array($this->__fieldobjects[$k])) {
                     $do = $this->__fieldobjects[$k]["object"];
                     $list = $do->getList();
                     $key = $this->__fieldobjects[$k]["property"];
                     $sout = "<select  " . ($errors[$k] ? "class=\"dataform_error\"" : "") . " name=\"" . $k . "\"><option value=\"0\">---</option>";
                     for ($li = 0; $li < count($list); $li++) {
                         if ($list[$li]["id"] != $v) {
                             $sout .= "<option value=\"" . $list[$li]["id"] . "\">" . $list[$li][$key] . "</option>";
                         } else {
                             $sout .= "<option value=\"" . $list[$li]["id"] . "\" selected style=\"font-weight:bold\">" . $list[$li][$key] . "</option>";
                         }
                     }
                     $sout .= "</select>";
                     $out .= $sout . "</td>" . ($count % 2 == 0 ? "</tr>" : "") . "";
                     $count++;
                     continue;
                 }
                 if (is_array($this->__fieldwidgets[$k])) {
                     if (is_object($this->__fieldwidgets[$k]["entity"]) === false) {
                         $ef = $this->__fieldwidgets[$k]["entityfield"];
                         $eo = new $this->__fieldwidgets[$k]["entity"]();
                         $eo->{$ef} = $v;
                         $w = new $this->__fieldwidgets[$k]["widget"]();
                         $w->drop($eo);
                     } else {
                         $eo = $this->__fieldwidgets[$k]["entity"];
                         $do = new dataobject();
                         foreach ($rows[$i] as $w => $s) {
                             $do->{$w} = $s;
                         }
                         $eo->drop($do);
                         $w = new $this->__fieldwidgets[$k]["widget"]();
                         $w->drop($eo);
                     }
                     $out .= $w->draw() . "</td>" . ($count % 2 == 0 ? "</tr>" : "") . "";
                     $count++;
                     continue;
                 }
                 switch ($o->__datafields[$k]) {
                     case "bool":
                         $out .= "<input " . ($fc == 0 ? "id=\"first\"" : "") . " " . ($errors[$k] ? "class=\"dataform_error\"" : "") . " type=\"checkbox\" name=\"" . $k . "\" " . ($v == true ? "checked" : "") . " />&nbsp;</input>";
                         break;
                     case "int":
                         $out .= "<input  " . ($fc == 0 ? "id=\"first\"" : "") . " " . ($errors[$k] ? "class=\"dataform_error\"" : "") . " type=\"text\" " . ($this->__disabled[$k] ? "readonly=\"readonly\"" : "") . " name=\"" . $k . "\" value=\"" . $v . "\" size=\"10\"/>";
                         break;
                     case "float":
                         $out .= "<input " . ($fc == 0 ? "id=\"first\"" : "") . " " . ($errors[$k] ? "class=\"dataform_error\"" : "") . " type=\"text\" " . ($this->__disabled[$k] ? "readonly=\"readonly\"" : "") . " name=\"" . $k . "\" value=\"" . $v . "\" size=\"10\"/>";
                         break;
                     case "varchar":
                         $out .= "<input " . ($fc == 0 ? "id=\"first\"" : "") . "  " . ($errors[$k] ? "class=\"dataform_error\"" : "") . "type=\"text\" " . ($this->__disabled[$k] ? "readonly=\"readonly\"" : "") . " name=\"" . $k . "\" value=\"" . $v . "\" size=\"30\"/>";
                         break;
                     case "text":
                         $out .= "<textarea  " . ($fc == 0 ? "id=\"first\"" : "") . " " . ($errors[$k] ? "class=\"dataform_error\"" : "") . "cols=\"40\" rows=\"4\" name=\"" . $k . "\">" . $v . "</textarea>";
                         break;
                         $fc++;
                         // hack para obtener foco en el primer field del formulario
                 }
             }
             $count++;
             $out .= "</td>" . ($count % 2 == 0 ? "</tr>" : "") . "";
         }
     }
     $out .= "\n\t\t<script>\n\t\tfunction getFocus()\n\t\t{\n\t\t\t\tf = document.getElementById('first').focus();\n\t\t}\n\t\tgetFocus();\n\t\t</script>";
     $out .= "<tr><td colspan=\"2\"><button onclick=\"document.getElementById('" . $this->name . "').submit();\"><img src=\"icons/16x16/resultset_next.png\">" . $this->submit . "</button> </td></tr></table></form>";
     return $out;
 }