Skip to content

Commit

Permalink
Patch 0.6 (#19)
Browse files Browse the repository at this point in the history
* Added "admin" user in database creation script

* Added index.php in .gitignore

* Updated Item form and item->create controller

When creating a new item, get the new ID with CodeIgniter
$this->db->insert_id() method (line 235)

* Moved new item button to the top of the list

* Modifications by Tombez Rémy

- Correcting Image Upload
- Correcting Form content issues
- Correcting Delete confirmation, now make the user go back to previous page when they choose No.

* serial number and create without image corrected

-Corrected serial number empty when modifying a Item.
- Corrected issue who forced to upload a image to save a Item.
  • Loading branch information
DidierViret authored Jul 7, 2017
1 parent 934876f commit 458502a
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 117 deletions.
5 changes: 5 additions & 0 deletions .buildpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path=""/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk

# Some config files
# =========================
index.php
application/config/config.php
application/config/database.php
22 changes: 22 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>stock</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.dltk.core.scriptbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.php.core.PHPNature</nature>
</natures>
</projectDescription>
81 changes: 41 additions & 40 deletions application/controllers/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public function view($id = NULL)
->with('item_condition')
->with('item_group')
->get($id);

$output['item'] = $item;
$output['item'] = $item;

$this->display_view('item/detail', $output);
}
Expand All @@ -189,36 +189,34 @@ public function create()

$this->form_validation->set_rules("inventory_number", "N° d'inventaire", 'required|callback_unique_inventory_nb',
array('required' => "L'item doit avoir un numero d'inventaire"));

// Get the ID that the new item will receive if it is created now
$data['item_id'] = $this->item_model->get_future_id();

$data['upload_errors'] = "";
if (isset($_POST['photo'])) {
// IMAGE UPLOADING
//$config['upload_path'] = './uploads/images/';
$config['upload_path'] = 'C:\\wamp64\\www\\stock\\uploads\\images\\'; //TOUJOURS INVALIDE
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 550;
$config['max_height'] = 550;

$this->load->library('upload');
$this->upload->initialize($config);

if ($this->upload->do_upload('photo'))
{
$itemArray['image'] = $this->upload->data('file_name');
} else {
$data['upload_errors'] = $this->upload->display_errors();
$upload_failed = TRUE;
}
}


// If there is no problem with the form (including the image)
if ($this->form_validation->run() === TRUE && !isset($upload_failed)) {
$itemArray = array();

//$itemArray = array();

if (isset($_FILES)) {
// IMAGE UPLOADING
$config['upload_path'] = './uploads/images/';
//$config['upload_path'] = 'C:\\wamp64\\www\\stock\\uploads\\images\\'; //TOUJOURS INVALIDE
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 550;
$config['max_height'] = 550;

$this->load->library('upload');
$this->upload->initialize($config);

if ($this->upload->do_upload('photo'))
{
$itemArray['image'] = $this->upload->data('file_name');
} else {
$data['upload_errors'] = $this->upload->display_errors();
$upload_failed = TRUE;
}
}

$linkArray = array();

$this->load->model('item_tag_link_model');
Expand All @@ -235,15 +233,17 @@ public function create()
$itemArray["created_by_user_id"] = $_SESSION['user_id'];

$this->item_model->insert($itemArray);
$item_id = $this->db->insert_id();

foreach ($linkArray as $tag) {
$this->item_tag_link_model->insert(array("item_tag_id" => $tag, "item_id" => ($data['item_id'])));
$this->item_tag_link_model->insert(array("item_tag_id" => $tag, "item_id" => ($item_id)));
}

header("Location: " . base_url() . "item/view/" . $data['item_id']);
header("Location: " . base_url() . "item/view/" . $item_id);
exit();

// Display form to complete it
} else {
// Load the options
// Load the comboboxes options
$this->load->model('stocking_place_model');
$data['stocking_places'] = $this->stocking_place_model->get_all();
$this->load->model('supplier_model');
Expand All @@ -252,17 +252,19 @@ public function create()
$data['item_groups'] = $this->item_group_model->get_all();
$this->load->model('item_condition_model');
$data['condishes'] = $this->item_condition_model->get_all();

// Load the tags
$this->load->model('item_tag_model');
$data['item_tags'] = $this->item_tag_model->get_all();

$data['item_tags'] = $this->item_tag_model->get_all();

$this->display_view('item/form', $data);

$this->display_view('item/form', $data);
}

// Creation is not allowed for the non-connected users, which are sent to the connection page
} else {
header("Location: " . base_url() . "auth/login");
exit();
} else {
header("Location: " . base_url() . "auth/login");
exit();
}
}

Expand Down Expand Up @@ -491,7 +493,6 @@ public function modify($id)

// Execute the changes in the item table
$this->item_model->update($id, $itemArray);

redirect("/item/view/" . $id);
exit();
} else {
Expand Down Expand Up @@ -551,7 +552,7 @@ public function delete($id, $command = NULL)
header("Location: " . base_url() . "auth/login");
exit();
}
}
}

public function delete_loan($id, $command = NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/item_groups/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<form class="container" method="post">
<div class="form-input">
<label for="name">Nom:</label>
<input type="text" class="form-control" name="name" id="name" value="<?php if (isset($name)) {echo $name;} else {echo set_value('name');} ?>" />
<input type="text" class="form-control" name="name" id="name" value="<?php if (isset($name)) {echo set_value('name',$name);} else {echo set_value('name');} ?>" />
</div><br />
<button type="submit" class="btn btn-primary"><?php echo $this->lang->line('btn_submit'); ?></button>
<a class="btn btn-primary" href="<?php echo base_url() . "admin/view_item_groups/"; ?>"><?php echo $this->lang->line('btn_cancel'); ?></a>
Expand Down
4 changes: 2 additions & 2 deletions application/views/admin/stocking_places/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
<form class="container" method="post">
<div class="form-input">
<label for="short">Nom court:</label>
<input type="text" class="form-control" name="short" id="short" value="<?php if (isset($short)) {echo $short;} else {echo set_value('short');} ?>" />
<input type="text" class="form-control" name="short" id="short" value="<?php if (isset($short)) {echo set_value('short',$short);} else {echo set_value('short');} ?>" />
</div>
<div class="form-input">
<label for="name">Nom long:</label>
<input type="text" class="form-control" name="name" id="name" value="<?php if (isset($name)) {echo $name;} else {echo set_value('name');} ?>" />
<input type="text" class="form-control" name="name" id="name" value="<?php if (isset($name)) {echo set_value('name',$name);} else {echo set_value('name');} ?>" />
</div><br />
<button type="submit" class="btn btn-primary"><?php echo $this->lang->line('btn_submit'); ?></button>
<a class="btn btn-primary" href="<?php echo base_url() . "admin/view_stocking_places/"; ?>"><?php echo $this->lang->line('btn_cancel'); ?></a>
Expand Down
14 changes: 7 additions & 7 deletions application/views/admin/suppliers/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,31 @@
<form class="container" method="post">
<div class="form-input">
<label for="name">Nom:</label>
<input type="text" class="form-control" name="name" id="name" value="<?php if (isset($name)) {echo $name;} else {echo set_value('name');} ?>" />
<input type="text" class="form-control" name="name" id="name" value="<?php if (isset($name)) {echo set_value('name',$name);} else {echo set_value('name');} ?>" />
</div><br />
<div class="form-input">
<label for="name">Première ligne d'adresse:</label>
<input type="text" class="form-control" name="address_line1" id="address_line1" value="<?php if (isset($address_line1)) {echo $address_line1;} else {echo set_value('address_line1');} ?>" />
<input type="text" class="form-control" name="address_line1" id="address_line1" value="<?php if (isset($address_line1)) {echo set_value('adress_line1',$address_line1);} else {echo set_value('address_line1');} ?>" />
</div><br />
<div class="form-input">
<label for="name">Deuxième ligne d'adresse:</label>
<input type="text" class="form-control" name="address_line2" id="address_line2" value="<?php if (isset($address_line2)) {echo $address_line2;} else {echo set_value('address_line2');} ?>" />
<input type="text" class="form-control" name="address_line2" id="address_line2" value="<?php if (isset($address_line2)) {echo set_value('adress_line2',$address_line2);} else {echo set_value('address_line2');} ?>" />
</div><br />
<div class="form-input">
<label for="name">NPA:</label>
<input type="number" min="1000" class="form-control" name="zip" id="zip" value="<?php if (isset($zip)) {echo $zip;} else {echo set_value('zip');} ?>" />
<input type="number" min="1000" class="form-control" name="zip" id="zip" value="<?php if (isset($zip)) {echo set_value('zip',$zip);} else {echo set_value('zip');} ?>" />
</div><br />
<div class="form-input">
<label for="name">Ville:</label>
<input type="text" class="form-control" name="city" id="city" value="<?php if (isset($city)) {echo $city;} else {echo set_value('city');} ?>" />
<input type="text" class="form-control" name="city" id="city" value="<?php if (isset($city)) {echo set_value('city',$city);} else {echo set_value('city');} ?>" />
</div><br />
<div class="form-input">
<label for="name">Téléphone:</label>
<input type="text" class="form-control" name="tel" id="tel" value="<?php if (isset($tel)) {echo $tel;} else {echo set_value('tel');} ?>" />
<input type="text" class="form-control" name="tel" id="tel" value="<?php if (isset($tel)) {echo set_value('tel',$tel);} else {echo set_value('tel');} ?>" />
</div><br />
<div class="form-input">
<label for="name">E-mail:</label>
<input type="text" class="form-control" name="email" id="email" value="<?php if (isset($email)) {echo $email;} else {echo set_value('email');} ?>" />
<input type="text" class="form-control" name="email" id="email" value="<?php if (isset($email)) {echo set_value('email',$email);} else {echo set_value('email');} ?>" />
</div><br />
<button type="submit" class="btn btn-primary"><?php echo $this->lang->line('btn_submit'); ?></button>
<a class="btn btn-primary" href="<?php echo base_url() . "admin/view_suppliers/"; ?>"><?php echo $this->lang->line('btn_cancel'); ?></a>
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/tags/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<form class="container" method="post">
<div class="form-input">
<label for="name"><?php if ($update_tag) { ?>Entrer le nouveau nom:<?php } else { ?>Entrer le nom du nouveau tag:<?php } ?></label>
<input type="text" class="form-control" name="name" id="name" value="<?php if (isset($name)) {echo $name;} else {echo set_value('name');} ?>" />
<input type="text" class="form-control" name="name" id="name" value="<?php if (isset($name)) {echo set_value('name',$name);} else {echo set_value('name');} ?>" />
</div><br />
<button type="submit" class="btn btn-primary"><?php echo $this->lang->line('btn_submit'); ?></button>
<a class="btn btn-primary" href="<?php echo base_url() . "admin/view_tags/"; ?>"><?php echo $this->lang->line('btn_cancel'); ?></a>
Expand Down
8 changes: 4 additions & 4 deletions application/views/admin/users/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@
<form class="container" method="post">
<div class="form-group">
<label for="username">Identifiant :</label>
<input class="form-control" name="username" id="username" value="<?php if (isset($username)) {echo $username;} else {echo set_value('username');} ?>" />
<input class="form-control" name="username" id="username" value="<?php if (isset($username)) {echo set_value('username',$username);} else {echo set_value('username');} ?>" />
</div>

<div class="form-group">
<label for="lastname">Nom :</label>
<input class="form-control" name="lastname" id="lastname" value="<?php if (isset($lastname)) {echo $lastname;} else {echo set_value('lastname');} ?>" />
<input class="form-control" name="lastname" id="lastname" value="<?php if (isset($lastname)) {echo set_value('lastname',$lastname);} else {echo set_value('lastname');} ?>" />
</div>

<div class="form-group">
<label for="firstname">Prénom :</label>
<input class="form-control" name="firstname" id="firstname" value="<?php if (isset($firstname)) {echo $firstname;} else {echo set_value('firstname');} ?>" />
<input class="form-control" name="firstname" id="firstname" value="<?php if (isset($firstname)) {echo set_value('firstname',$firstname);} else {echo set_value('firstname');} ?>" />
</div>

<div class="form-group">
<label for="email">E-mail :</label>
<input class="form-control" name="email" id="email" value="<?php if (isset($email)) {echo $email;} else {echo set_value('email');} ?>" type="email" />
<input class="form-control" name="email" id="email" value="<?php if (isset($email)) {echo set_value('email',$email);} else {echo set_value('email');} ?>" type="email" />
</div>

<div class="form-group"><label for="user_type_id">Statut :</label>
Expand Down
2 changes: 1 addition & 1 deletion application/views/item/confirm_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

<div class="btn-group">
<a href="<?php echo base_url().uri_string()."/confirmed";?>" target="_parent" class="btn btn-success">Oui</a>
<a href="<?php echo base_url().'item/view/'.$id;?>" target="_parent" class="btn btn-danger">Non</a>
<a href="javascript:window.history.back()" target="_parent" class="btn btn-danger">Non</a>
</div>
</div>
Loading

0 comments on commit 458502a

Please sign in to comment.