Ejemplo n.º 1
0
function add_PO($forms)
{
    global $DB, $LMS, $UKE;
    $obj = new xajaxResponse();
    $form = $forms['poedit'];
    $blad = false;
    $obj->script("removeClassId('id_shortname','alerts');");
    $obj->assign("id_shortname_alerts", "innerHTML", "");
    $obj->script("removeClassId('id_name','alerts');");
    $obj->assign("id_name_alerts", "innerHTML", "");
    $obj->script("removeClassId('id_ten','alerts');");
    $obj->assign("id_ten_alerts", "innerHTML", "");
    $obj->script("removeClassId('id_regon','alerts');");
    $obj->assign("id_regon_alerts", "innerHTML", "");
    $obj->script("removeClassId('id_rpt','alerts');");
    $obj->assign("id_rpt_alerts", "innerHTML", "");
    $obj->script("removeClassId('location','alerts');");
    $obj->script("removeClassId('id_states','alerts');");
    $obj->script("removeClassId('id_districts','alerts');");
    $obj->script("removeClassId('id_boroughs','alerts');");
    $obj->script("removeClassId('id_city','alerts');");
    $obj->script("removeClassId('id_street','alerts');");
    $obj->script("removeClassId('id_location_house','alerts');");
    $obj->script("removeClassId('id_zip','alerts');");
    $obj->assign("id_zip_alerts", "innerHTML", "");
    if (!$form['shortname']) {
        $obj->script("addClassId('id_shortname','alerts');");
        $obj->assign("id_shortname_alets", "innerHTML", "Identyfikator jest wymagany");
        $blad = true;
    }
    if (!$form['name']) {
        $obj->script("addClassId('id_name','alerts');");
        $obj->assign("id_name_alets", "innerHTML", "Nazwa firmy jest wymagana");
        $blad = true;
    }
    if (!$form['ten']) {
        $obj->script("addClassId('id_ten','alerts');");
        $blad = true;
    } elseif (!check_ten($form['ten'])) {
        $obj->script("addClassId('id_ten','alerts');");
        $obj->assign('id_ten_alerts', 'innerHTML', 'Błędny numer NIP');
        $blad = true;
    }
    if (!$form['regon']) {
        $obj->script("addClassId('id_regon','alerts');");
        $blad = true;
    } elseif (!check_regon($form['regon'])) {
        $obj->script("addClassId('id_regon','alerts');");
        $obj->assign('id_regon_alerts', 'innerHTML', 'Błędny numer REGON');
        $blad = true;
    }
    if (!$form['rpt']) {
        $obj->script("addClassId('id_rpt','alerts');");
        $blad = true;
    } elseif (!is_natural($form['rpt'])) {
        $obj->script("addClassId('id_rpt','alerts');");
        $obj->assign('id_rpt_alerts', 'innerHTML', 'Błednie podano numer RPT');
        $blad = true;
    }
    if (!$form['teryt']) {
        if (!$form['states']) {
            $obj->script("addClassId('id_states','alerts');");
            $blad = true;
        }
        if (!$form['districts']) {
            $obj->script("addClassId('id_districts','alerts');");
            $blad = true;
        }
        if (!$form['boroughs']) {
            $obj->script("addClassId('id_boroughs','alerts');");
            $blad = true;
        }
        if (!$form['city']) {
            $obj->script("addClassId('id_city','alerts');");
            $blad = true;
        }
    } elseif (!$form['location']) {
        $obj->script("addClassId('location','alerts');");
        $blad = true;
    }
    if (!$form['location_house']) {
        $obj->script("addClassId('id_location_house','alerts');");
        $blad = true;
    }
    if (!$form['zip']) {
        $obj->script("addClassId('id_zip','alerts');");
        $blad = true;
    } elseif (!check_zip($form['zip'])) {
        $obj->script("addClassId('id_zip','alerts');");
        $obj->assign("id_zip_alerts", "innerHTML", "Błędny kod pocztowy");
        $blad = true;
    }
    if (!$blad) {
        if ($form['teryt']) {
            $data = $LMS->GetTerytCode($form['location_city'], $form['location_street']);
            $form['states'] = $data['name_states'];
            $form['districts'] = $data['name_districts'];
            $form['boroughs'] = $data['name_boroughs'];
            $form['city'] = $data['name_city'];
            $form['street'] = $data['name_street'];
            $form['kod_terc'] = $data['kod_terc'];
            $form['kod_simc'] = $data['kod_simc'];
            $form['kod_ulic'] = $data['kod_ulic'];
            unset($data);
        } else {
            $form['kod_terc'] = $form['kod_simc'] = $form['kod_ulic'] = 0;
            $form['location_city'] = $form['location_street'] = NULL;
        }
        $data = array();
        $data['id'] = $form['id'];
        $data['rapid'] = $form['idr'];
        $data['mark'] = 'PO';
        $data['markid'] = $form['shortname'];
        $action = $form['action'];
        unset($form['id']);
        unset($form['action']);
        $data['data'] = serialize($form);
        if ($action == 'add') {
            $UKE->add_siis_data_po($data);
            $obj->script("loadAjax('id_data','?m=uke_siis_info&tuck=PO&idr=" . $data['rapid'] . "');");
        } elseif ($action == 'edit') {
            $UKE->update_siis_data_po($data);
            $obj->script("loadAjax('id_data','?m=uke_siis_info&tuck=PO&idr=" . $data['rapid'] . "');");
        }
    }
    return $obj;
}
Ejemplo n.º 2
0
 /**
  * Function to create a new entry for a chapter from scratch. It creates
  * both a directory and a database entry, and removes them if something
  * goes wrong.
  *
  * @author	Woxxy
  * @param	array $data with the minimal values, or the function will return
  * 			false and do nothing.
  * @return	boolean true on success, false on failure.
  */
 public function add($data)
 {
     // Let's make so subchapters aren't empty, so it's at least 0 for all
     // the addition of the chapter.
     if (!isset($data["subchapter"]) || !is_natural($data["subchapter"])) {
         $data["subchapter"] = 0;
     }
     // Create a stub that is humanly readable, for the worst cases.
     $this->to_stub = $data['chapter'] . "_" . $data['subchapter'] . "_" . $data['name'];
     // uniqid prevents us from having sad moments due to identical directory names
     $this->uniqid = uniqid();
     // Stub function converts the $this->to_stub if available, and processes it.
     $this->stub = $this->stub();
     // Check if comic_id is set and confirm there's a corresponding serie
     // If not, make an error message and stop adding the chapter
     $comic = new Comic($data['comic_id']);
     if ($comic->result_count() == 0) {
         set_notice('error', _('The series you were adding the chapter to doesn\'t exist.'));
         log_message('error', 'add: comic_id does not exist in comic database');
         return false;
     }
     // The series exists? Awesome, set it as soon as possible.
     $this->comic_id = $data['comic_id'];
     // Create the directory. The GUI error messages are inside the function.
     if (!$this->add_chapter_dir()) {
         log_message('error', 'add: failed creating dir');
         return false;
     }
     // Hoping we got enough $data, let's throw it to the database function.
     // In case it fails, it will remove the directory.
     if (!$this->update_chapter_db($data)) {
         $this->remove_chapter_dir();
         log_message('error', 'add: failed adding to database');
         return false;
     }
     // Oh, since we already have the series, let's put it into its variable.
     // This is very comfy for redirection!
     $this->comic = $comic;
     // All good? Return true!
     return true;
 }