Subversion Repositories SmartDukaan

Rev

Rev 4024 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4007 chandransh 1
#!/bin/bash
2
 
3
if [ $# -lt 3 ]
4
then
5
	echo "Usage: $0 <from> <passwd> <email> [<email> ...]"
6
	exit  1
7
fi
8
 
9
# resolve links - $0 may be a softlink
10
PRG="$0"
11
 
12
while [ -h "$PRG" ]; do
13
  ls=`ls -ld "$PRG"`
14
  link=`expr "$ls" : '.*-> \(.*\)$'`
15
  if expr "$link" : '/.*' > /dev/null; then
16
    PRG="$link"
17
  else
18
    PRG=`dirname "$PRG"`/"$link"
19
  fi
20
done
21
 
22
# Get standard environment variables
23
PRGDIR=`dirname $(readlink -f "$PRG")`
24
PYTHON_DIR="${PRGDIR}/../PyProj/src/shop2020/utils"
25
DATE=`date +%Y-%b-%d`
26
 
27
#Email the two report files.
28
 
29
FROM=$1
30
PASSWD=$2
31
 
32
shift 2
33
 
34
TO_LIST=""
35
while (( "$#" ))
36
do
37
	TO_LIST="${TO_LIST} -t $1"
38
	shift
39
done
40
 
41
HOST="192.168.190.114"
42
#HOST="localhost"
43
 
44
mysql -uroot -pshop2020 -h ${HOST} catalog -e "select i.brand as 'Brand', (case i.model_name when null then ' ' else i.model_name end) as 'Model Name', i.model_number as 'Model Number', (case i.color when null then ' ' else i.color end) as 'Color', sum(c.availibility) as 'Available', sum(c.reserved) as 'Pending', sum(c.reserved) - sum(c.availibility) as 'Required' from currentinventorysnapshot c, item i where c.item_id = i.id and c.reserved > 0 group by i.id order by i.brand, i.model_name, i.model_number, i.color" > /tmp/pending-orders.csv
45
 
46
${PYTHON_DIR}/CsvToXlsConvertor.py -o /tmp/inventory-stock-required.${DATE}.xls /tmp/pending-orders.csv
47
 
48
python ${PYTHON_DIR}/EmailAttachmentSender.py -f ${FROM} -p ${PASSWD} ${TO_LIST} -s "Inventory Stock required by Spice Online Retail" -a /tmp/inventory-stock-required.${DATE}.xls
49
 
50
rm /tmp/inventory-stock-required.${DATE}.xls