Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandod1 committed Jan 3, 2021
1 parent 63e86dc commit 316a4c2
Show file tree
Hide file tree
Showing 31 changed files with 1,694 additions and 3 deletions.
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2021 Fernando
Copyright (c) 2020 Fernando
Url: https://github.com/fernandod1/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# Laser-hair-removal-app
Full php app control panel to administrate clients database and sessions of laser hair removal in a beauty center.
# Laser hair removal app to manage client's threataments in beauty center

Full PHP script control panel to manage client's database and sessions of laser hair removal threataments in a beauty center.

## Features:

- Add, edit, remove clients.
- List all clients or search one client.
- Upload system of client's disclaimer threatament documents.
- Add, remove new threatament to client. (Mode just one session or Pack of 5 sessions ("bonus pack")).
- Consume session of client.
- Counter of sessions left of each threatament of client.
- Option "pay before session threatament" or "pending payment" label reminder).
- Note: script is actually only translated to spanish, sorry.

## Requirements

PHP and MySQL database.

## Instalation

1.) Import in MySQL tables struct from database_struct.sql.
2.) Configure MySQL connection parameters in connectDB.php.
3.) Set in upload.php file full path to /documents/ folder where will be stored client's disclaimer threatament documents.
4.) Upload all files to your hosting. Done.

## Screenshots
Main page of control panel:
<img src=screenshots/01.jpg width=500>

Listing clients:
<img src=screenshots/02.jpg width=500>

Add new client to database:
<img src=screenshots/03.jpg width=500>

Client threataments and sessions consumption:
<img src=screenshots/04.jpg width=500>

Add new threatament:
<img src=screenshots/05.jpg width=500>

Sessions consumption page:
<img src=screenshots/06.jpg width=500>

Client's disclaimer threatament documents upload:
<img src=screenshots/07.jpg width=500>

## Collaborations

Collaborations to improve script are always welcome.
144 changes: 144 additions & 0 deletions clients.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?
class Clients
{

function __construct()
{

}


public function getClients($db,$page){
$offset=paginate($db,$page,"all");
$results = $db->getData("SELECT * FROM clients ORDER BY lastname ASC LIMIT $offset,10");
if($results){
$template = new Template;
$template->load("templates/client_list_all.php");
$template->replace("data", $results);
$template->publish();
}
}


public function searchClients($db,$word){
$results = $db->getData("SELECT * FROM clients WHERE ( lastname LIKE '%".$word."%' OR name LIKE '%".$word."%' OR phone LIKE '%".$word."%' ) ORDER BY lastname ASC");
if($results){
$template = new Template;
$template->load("templates/client_list_all.php");
$template->replace("data", $results);
$template->publish();
}
}

public function formAddClients(){
$template = new Template;
$template->load("templates/client_form_add.php");
$data=array(
'op'=>'adding',
'cid'=>'',
'name'=>'',
'lastname'=>'',
'yearborn'=>'',
'sex'=>'',
'address'=>'',
'phone'=>'',
'email'=>'',
'coloreyes'=>'',
'colorhair'=>'',
'skintype'=>'',
'other'=>''
);
$template->replace("data", $data);
$template->publish();
}

public function addClients($db,$name,$lastname,$yearborn,$sex,$address,$phone,$email,$coloreyes,$colorhair,$skintype,$other){
$result = $db->executeInstruction("
INSERT INTO `clients` (`name`, `lastname`, `yearborn`, `sex`, `address`, `phone`, `email`, `coloreyes`, `colorhair`, `skintype`, `other`, `dateadded`)
VALUES ('".$name."', '".$lastname."', '".$yearborn."', '".$sex."', '".$address."', '".$phone."', '".$email."', '".$coloreyes."', '".$colorhair."', '".$skintype."', '".$other."', '".date("Y-m-d")."');
");
$template = new Template;
$template->load("templates/alert_message.php");
if($result){
$data=array(
'type'=>'alert-success',
'message'=>'Datos de cliente insertados con &eacute;xito en la base de datos.'
);
}else{
$data=array(
'type'=>'alert-danger',
'message'=>'Error. No fue posible insertar los datos de cliente en la base de datos.'
);
}
$template->replace("data", $data);
$template->publish();
}

public function formEditClients($db,$id){
$result = $db->getDataSingle("SELECT * FROM `clients` WHERE `id` = '".$id."'");
if($result){
$template = new Template;
$template->load("templates/client_form_edit.php");
$result['op']='editing';
$template->replace("data", $result);
$template->publish();
}
}

public function editClients($db,$name,$lastname,$yearborn,$sex,$address,$phone,$email,$coloreyes,$colorhair,$skintype,$other,$cid){
$result = $db->executeInstruction("UPDATE `clients` SET `name`='".$name."', `lastname`='".$lastname."', `yearborn`='".$yearborn."', `sex`='".$sex."', `address`='".$address."', `phone`='".$phone."', `email`='".$email."', `coloreyes`='".$coloreyes."', `colorhair`='".$colorhair."', `skintype`='".$skintype."', `other`='".$other."' WHERE `id` = '".$cid."'");
if($result){
$template = new Template;
$template->load("templates/alert_message.php");
$data=array(
'type'=>'alert-success',
'message'=>'Datos de cliente modificados con &eacute;xito.<br><br> <a href=orders.php?op=view&cid='.sanitize($_POST['cid']).'&name='.sanitize($_POST['name']).'&lastname='.sanitize($_POST['lastname']).'><b>Volver a ficha de cliente</b></a>'
);
$template->replace("data", $data);
$template->publish();
}
}

public function uploadClients(){
$template = new Template;
$template->load("templates/client_form_edit.php");
$result['op']='uploading';
$template->replace("data", $result);
$template->publish();
}

public function formRemoveClients($cid,$name,$lastname) {
$template = new Template;
$template->load("templates/client_form_remove.php");
$data=array(
'op'=>'removing',
'cid'=>$cid,
'name'=>$name,
'lastname'=>$lastname
);
$template->replace("data", $data);
$template->publish();
}

public function removeClients($db,$cid) {
$result = $db->executeInstruction("DELETE FROM `clients` WHERE `id` = '".$cid."'");
$template = new Template;
$template->load("templates/alert_message.php");
if($result){
$data=array(
'type'=>'alert-success',
'message'=>'Datos de cliente eliminados con &eacute;xito.'
);
}
else{
$data=array(
'type'=>'alert-danger',
'message'=>'Error. No fue posible eliminar los datos de cliente.'
);
}
$template->replace("data", $data);
$template->publish();
}
}

?>
76 changes: 76 additions & 0 deletions clients.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
require 'functions.php';
require 'mysqldatabase.class.php';
require 'template.class.php';
require 'clients.class.php';
require 'connectDB.php';

include('templates/header.php');

$db = new MySQLDatabase($HOST,$USERNAME,$PASSWORD,$DATABASE);
$db->connect();
if(isset($_REQUEST['op']))
$op = sanitize($_REQUEST['op']);
else
$op = "";
$client = new Clients;
switch($op) {
default:
echo '<br>';
if(isset($_GET['page']))
$page=sanitize($_GET['page']);
else
$page=1;
if(isPositiveValue($page))
$client->getClients($db,$page);
break; break;
case "searching":
echo '<br>';
if(isset($_POST['word'])&&$_POST['word']!=""){
$word=sanitize($_POST['word']);
$client->searchClients($db,$word);
}
break;
case "add":
$client->formAddClients();
break;
case "adding":
$client->formAddClients($db,sanitize($_POST['name']),sanitize($_POST['lastname']),sanitize($_POST['yearborn']),sanitize($_POST['sex']),sanitize($_POST['address']),sanitize($_POST['phone']),sanitize($_POST['email']),sanitize($_POST['coloreyes']),sanitize($_POST['colorhair']),sanitize($_POST['skintype']),sanitize($_POST['other']));
break;
case "edit":
$id=sanitize($_GET['cid']);
if(isPositiveValue($id))
$client->formEditClients($db,$id);
break;
case "editing":
$id=sanitize($_POST['cid']);
if(isPositiveValue($id))
$client->editClients($db,sanitize($_POST['name']),sanitize($_POST['lastname']),sanitize($_POST['yearborn']),sanitize($_POST['sex']),sanitize($_POST['address']),sanitize($_POST['phone']),sanitize($_POST['email']),sanitize($_POST['coloreyes']),sanitize($_POST['colorhair']),sanitize($_POST['skintype']),sanitize($_POST['other']),$id);
break;
case "uploading":
$client->uploadClients();
break;
case "remove":
$id=sanitize($_GET['cid']);
if(isPositiveValue($id))
$client->formRemoveClients($id,sanitize($_GET['name']),sanitize($_GET['lastname']));
break;
case "removing":
$cid=sanitize($_POST['cid']);
if(isPositiveValue($cid))
$client->removeClients($db,$cid);
break;


}
$db->close();




include('templates/footer.php');

?>



6 changes: 6 additions & 0 deletions connectDB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
$HOST = 'localhost';
$USERNAME = 'your_mysql_username';
$PASSWORD = 'your_mysql_password';
$DATABASE = 'your_database_name';
?>
Loading

0 comments on commit 316a4c2

Please sign in to comment.